Skip to content

Instantly share code, notes, and snippets.

@sloria
Created September 9, 2015 00:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sloria/795686a107c0f9698152 to your computer and use it in GitHub Desktop.
Save sloria/795686a107c0f9698152 to your computer and use it in GitHub Desktop.
#compdef ped
# vim: ft=zsh sw=2 ts=2 et
_ped() {
local curcontext="$curcontext" state line
integer NORMARG
typeset -A opt_args
_arguments -C -s -n \
'(- -h --help)'{-h,--help}'[Show help message]' \
'(- -v --version)'{-v,--version}'[Print version and exit]' \
'(- -e --editor)'{-e,--editor}'[Editor to use]' \
'(- -i --info)'{-i,--info}'[Print module name, path, and line number]' \
'1: :->module'
case $state in
module)
if [[ CURRENT -eq NORMARG ]]
then
# If the current argument is the first non-option argument
# then complete with python modules
cmds=( ${(uf)"$(ped ${words[CURRENT]} --complete)"} )
_arguments '1:modules:(${cmds})'
_message -e patterns 'pattern' && ret=0
fi
;;
*)
esac
}
_ped "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment