Skip to content

Commit

Permalink
Fix zsh completion script (#12173)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg authored Oct 7, 2023
2 parents b551c09 + dba399f commit 9b73482
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions news/12166.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix completion script for zsh
15 changes: 12 additions & 3 deletions src/pip/_internal/commands/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@
""",
"zsh": """
#compdef -P pip[0-9.]#
compadd $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$((CURRENT-1)) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )
__pip() {{
compadd $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$((CURRENT-1)) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )
}}
if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
# autoload from fpath, call function directly
__pip "$@"
else
# eval/source/. command, register function for later
compdef __pip -P 'pip[0-9.]#'
fi
""",
"fish": """
function __fish_complete_pip
Expand Down
15 changes: 12 additions & 3 deletions tests/functional/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,18 @@
"zsh",
"""\
#compdef -P pip[0-9.]#
compadd $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$((CURRENT-1)) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )""",
__pip() {
compadd $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$((CURRENT-1)) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )
}
if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
# autoload from fpath, call function directly
__pip "$@"
else
# eval/source/. command, register function for later
compdef __pip -P 'pip[0-9.]#'
fi""",
),
(
"powershell",
Expand Down

0 comments on commit 9b73482

Please sign in to comment.