Open martinmaehlmann opened 3 years ago
It doesn't a throw an error for me on my oh-my-zsh setup with zsh 5.8 (x86_64-apple-darwin20.0). Can we first try to figure out what causes the error?
The error is thrown, when the autocompletions are loaded, e.g. when I start a new instance of my zsh (zsh 5.7.1 (x86_64-apple-darwin19.0)). Despite the error thrown, the completion itself does work.
The error thrown due to the fact that the _arguments
are called outside a function. This is why I wrapped the completion scripts with an the functions __kubens()
and __kubectx()
silencing the error.
I was seeing this issue until I realised that rather than sourcing the completions they needed to be put into a directory on zsh's fpath
E.g. something like (untested)
# Create a folder ~/.zsh to put files zsh will load
mkdir "${HOME}/.zsh"
flamegraph --completions zsh > "${HOME}/.zsh/.flamegraph-completion.zsh"
# Add .zsh to your fpath when the zsh shell starts
echo 'fpath+=~/.zsh' >>"${HOME}/.zshrc"
hey @martinmaehlmann @ahmetb @thatmarkenglishguy did you find a solution?
--
MacOS Ventura 13.0.1 zsh 5.8.1 (x86_64-apple-darwin22.0) Antibody version dev (built from master)
In the antibody-plugins I loaded kubectx before I loaded ohmyzsh using ahmetb/kubectx path:completion kind:fpath
ok, I found a solution!
autoload -U compinit && compinit
after loading these completions)_arguments \
statement to _arguments >/dev/null 2>&1 \
sending a pr
I found this script somwhere and it helped, just copy and paste it into the zsh terminal and the commands will run just fine.
cd ~
mkdir ~/.zsh
swift package completion-tool generate-zsh-script > ~/.zsh/_swift
echo -e "fpath=(~/.zsh \$fpath)\n" >> ~/.zshrc
echo -e "autoload -Uz compinit && compinit" >> ~/.zshrc
The zsh completion scripts make zsh throw an error.
_arguments:comparguments:325: can only be called from completion function
This is due to the fact, that both zsh completion scripts call
_arguments
outside a function.Fix
Put the completion scripts into a function, as shown below:
kubectx.zsh
kubens.zsh