Skip to content

Instantly share code, notes, and snippets.

@jgdavey jgdavey/
Created Oct 2, 2011

What would you like to do?
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']##/:})
_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
return ret

This comment has been minimized.

Copy link
Owner Author

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
You can’t perform that action at this time.