-vvv option).Instructions on how to enable poetry completions for zsh with oh-my-zsh on https://python-poetry.org/docs/#enable-tab-completion-for-bash-fish-or-zsh don't do anything. Firstly, the oh-my-zsh plugin has to be named poetry.plugin.zsh, not _poetry. Secondly, it's better be installed into .oh-my-zsh/custom/plugins. Thirdly, when it's enabled with plugins(poetry ...), it results in a bunch of compinit error messages on start.
I found the following instructions to work on MacOS:
print -l $fpath | grep '.oh-my-zsh/completions'
mkdir ~/.oh-my-zsh/completions
poetry completions zsh > ~/.oh-my-zsh/completions/_poetry
rm ~/.zcompdump*
source ~/.zshrc throws no errors and gives correct completions.
A similar discussion:
https://github.com/gopasspw/gopass/issues/585
They work as expected (fedora 31 also here);
the only thing to do after the instuctions is to remove the ~/.zcompdump* file in the home directory.
After that, opening the terminal it will be recreated with poetry's completions enabled
Can confirm it works on MacOS as well, thanks @tsiq-alberto!
Firstly, the oh-my-zsh plugin has to be named
poetry.plugin.zsh, not_poetry. Secondly, it's better be installed into.oh-my-zsh/custom/plugins
Indeed, in case of oh-my-zsh it is recommended that custom plugins be installed at $ZSH_CUSTOM/plugins so it does not get deleted in updates.
However, it is not true that the file should be named poetry.plugin.zsh.
The oh-my-zsh.sh script (which is run at shell startup) contains the following lines:
is_plugin() {
local base_dir=$1
local name=$2
builtin test -f $base_dir/plugins/$name/$name.plugin.zsh \
|| builtin test -f $base_dir/plugins/$name/_$name
}
# Add all defined plugins to fpath. This must be done
# before running compinit.
for plugin ($plugins); do
if is_plugin $ZSH_CUSTOM $plugin; then
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
elif is_plugin $ZSH $plugin; then
fpath=($ZSH/plugins/$plugin $fpath)
else
echo "[oh-my-zsh] plugin '$plugin' not found"
fi
done
As per function is_plugin, either $name.plugin.zsh or _$name would be accepted and prepended into fpath (used by compinit later).
The difference is that _$name will not be explicitely sourced a bit later:
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
fi
done
The only thing that is missing in documentation and I had to do in order to have it working, it is removing ~/.zcompdump* as stated by @tsiq-alberto.
Most helpful comment
I found the following instructions to work on MacOS:
source ~/.zshrcthrows no errors and gives correct completions.A similar discussion:
https://github.com/gopasspw/gopass/issues/585