kislyuk / argcomplete

Python and tab completion, better together.
https://kislyuk.github.io/argcomplete/
Apache License 2.0
1.39k stars 129 forks source link

zsh: completion fails with script path starting with '~/' #469

Closed DiegoBaldassarMilleuno closed 5 months ago

DiegoBaldassarMilleuno commented 5 months ago

On zsh, argcomplete falls back to default completer for a command line like:

~/path/to/script.py --beginning-

This seems to be because in _python_argcomplete_global the tilde is not expanded to the absolute path of the home directory for zsh, unlike bash. The following fixed the problem for me:

diff --git a/opt/homebrew/share/zsh/site-functions/_python-argcomplete b/.oh-my-zsh/completions/_python-argcomplete
index 3023ff2..f58ab68 100644
--- a/opt/homebrew/share/zsh/site-functions/_python-argcomplete
+++ b/.oh-my-zsh/completions/_python-argcomplete
@@ -144,6 +144,7 @@ _python_argcomplete_global() {
         __python_argcomplete_expand_tilde_by_ref executable
     else
         executable="${words[1]}"
+        __python_argcomplete_expand_tilde_by_ref executable
         req_argv=( "${words[@]:1}" )
     fi

Tested on MacOS Sonoma 14.2.1, Zsh 5.9 (homebrew), argcomplete 3.2.1

kislyuk commented 5 months ago

Thank you for reporting. Fix released in v3.2.2.