Created
October 2, 2011 17:51
-
-
Save jgdavey/1257698 to your computer and use it in GitHub Desktop.
Hitch author completion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#compdef hitch | |
__hitch_authors() { | |
local expl | |
local -a _authors | |
if [ -f $HOME/.hitch_pairs ]; then | |
_authors=(${${(f)"$(cat $HOME/.hitch_pairs | awk '/:/ { print }')"}/:[ $'\t']##/:}) | |
fi | |
_describe -t hitch-authors 'hitch authors' _authors "$@" | |
} | |
_hitch() { | |
local state ret=1 | |
_arguments -C \ | |
'(- 1 *)'{-v,--version}'[Display version information]' \ | |
'(-h|--help)--help[Show help message]' \ | |
'(-u|--unhitch)'{-u,--unhitch}'+[Clear pair information]' \ | |
'(-e|--expire)'{-e,--expire}'+[Expire pair information in N hours]:number' \ | |
'(-s|--setup)--setup[Print out shell goodies]' \ | |
'*:: :->hitch_authors' && ret=0 | |
if [[ ${state} == "hitch_authors" ]]; then | |
_call_function ret __hitch_authors | |
fi | |
return ret | |
} | |
_hitch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save this file as
_hitch
and put it in yourfpath
. For example, I put the file in~/.zsh/functions/
, since that folder is included in myfpath
.In zsh,
fpath
works similarly toPATH
, only for zsh-specific functions. You can runecho $fpath
to view.