Skip to content

Commit

Permalink
shell_completion.py: Add support for zsh completion
Browse files Browse the repository at this point in the history
  • Loading branch information
kx-chen committed Jul 22, 2020
1 parent b8f5baa commit 6ed101d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/click/shell_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
COMP_CWORD=$COMP_CWORD \\
%(autocomplete_var)s=complete $1 )
# if [[ -z $response ]]; then
# COMPREPLY=""
# fi
for completion in $response; do
IFS=',' read type value <<< "$completion"
if [[ $type == 'dir' ]]; then
Expand Down Expand Up @@ -64,11 +60,17 @@
%(autocomplete_var)s=\"complete_zsh\" \\
%(script_names)s )}")
for key descr in ${(kv)response}; do
if [[ "$descr" == "_" ]]; then
for type key descr in ${response}; do
if [[ "$type" == "plain" ]]; then
if [[ "$descr" == "_" ]]; then
completions+=("$key")
else
else
completions_with_descriptions+=("$key":"$descr")
fi
elif [[ "$type" == "dir" ]]; then
_path_files -/
elif [[ "$type" == "file" ]]; then
_path_files -f
fi
done
Expand Down Expand Up @@ -205,6 +207,7 @@ def complete(self):

completions = do_complete(self.cli, self.prog_name, args, incomplete)
for item in completions:
echo(item[0])
echo(item[1])
echo(item[2] if item[2] else "_")

Expand Down

0 comments on commit 6ed101d

Please sign in to comment.