Skip to content

Instantly share code, notes, and snippets.

@jgdavey
Created October 2, 2011 17:51
Show Gist options
  • Save jgdavey/1257698 to your computer and use it in GitHub Desktop.
Save jgdavey/1257698 to your computer and use it in GitHub Desktop.
Hitch author completion
#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
@jgdavey
Copy link
Author

jgdavey commented Oct 2, 2011

Save this file as _hitch and put it in your fpath. For example, I put the file in ~/.zsh/functions/, since that folder is included in my fpath.

In zsh, fpath works similarly to PATH, only for zsh-specific functions. You can run echo $fpath to view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment