Skip to content

Commit

Permalink
Merge pull request #11417 from Freed-Wu/fix-zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed Jul 15, 2023
2 parents e53cf3d + fb45457 commit 324dd44
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
1 change: 1 addition & 0 deletions news/11416.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``pip completion --zsh``.
13 changes: 4 additions & 9 deletions src/pip/_internal/commands/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@
complete -o default -F _pip_completion {prog}
""",
"zsh": """
function _pip_completion {{
local words cword
read -Ac words
read -cn cword
reply=( $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$(( cword-1 )) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null ))
}}
compctl -K _pip_completion {prog}
#compdef -P pip[0-9.]#
compadd $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$((CURRENT-1)) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )
""",
"fish": """
function __fish_complete_pip
Expand Down
16 changes: 6 additions & 10 deletions tests/functional/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,10 @@
(
"zsh",
"""\
function _pip_completion {
local words cword
read -Ac words
read -cn cword
reply=( $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$(( cword-1 )) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null ))
}
compctl -K _pip_completion pip""",
#compdef -P pip[0-9.]#
compadd $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$((CURRENT-1)) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )""",
),
(
"powershell",
Expand Down Expand Up @@ -392,7 +387,8 @@ def test_completion_path_after_option(
)


@pytest.mark.parametrize("flag", ["--bash", "--zsh", "--fish", "--powershell"])
# zsh completion script doesn't contain pip3
@pytest.mark.parametrize("flag", ["--bash", "--fish", "--powershell"])
def test_completion_uses_same_executable_name(
autocomplete_script: PipTestEnvironment, flag: str, deprecated_python: bool
) -> None:
Expand Down

0 comments on commit 324dd44

Please sign in to comment.