Skip to content

Instantly share code, notes, and snippets.

@mgoodness
Last active December 24, 2023 15:36
Show Gist options
  • Save mgoodness/aa4026fa154ee859e661a0d8f0999361 to your computer and use it in GitHub Desktop.
Save mgoodness/aa4026fa154ee859e661a0d8f0999361 to your computer and use it in GitHub Desktop.
"New" (compsys) zsh completion script for pyenv
#compdef pyenv
# Ref: https://github.com/pyenv/pyenv/pull/1644
if [[ ! -o interactive ]]; then
return
fi
local state line
typeset -A opt_args
_arguments -C \
{--help,-h}'[Show help]' \
{--version,-v}'[Show pyenv version]' \
'(-): :->command' \
'*:: :->option-or-argument'
case "$state" in
(command)
local -a commands
commands=(${(f)"$(pyenv commands)"})
_describe -t commands 'command' commands
;;
(option-or-argument)
local -a args
args=(${(f)"$(pyenv completions ${line[1]})"})
_describe -t args 'arg' args
;;
esac
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment