Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: autocompletion's odd behaviour with packages installed through pip



> 2024/08/22 4:45, Silejonu <silejonu@xxxxxxxx> wrote:
> 
> Steps to reproduce:
>     • `python -m venv /tmp/test`
>     • `source /tmp/test/bin/activate`
>     • `pip install ansible`
>     • Type `ans` and hit tab to autocomplete
>     • Nothing happens (though syntax highlighting recognizes than `ansible` is a valid command)

This is not specific to pip.
zsh keeps an internal hash for all the commands in the PATH,
and this hash is not automatically updated when a new command
is added to your PATH.

A simple workaround is to manually run the rehash (or 'hash -r')
builtin to update the hash ('source activate' also does this):

% pip install ansible
% rehash
% ansi<TAB>

If you feel typing 'rehash' is tedious, then you can put

zstyle ':completion:*:commands' rehash on

into your .zshrc. Then 'rehash' is run every time you complete
a command name. If you don't notice any slowdown then this may be
the easiest solution.



Messages sorted by: Reverse Date, Date, Thread, Author