Skip to content

Instantly share code, notes, and snippets.

@tpope
Created February 19, 2009 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tpope/66935 to your computer and use it in GitHub Desktop.
Save tpope/66935 to your computer and use it in GitHub Desktop.
hcd() {
cd "$HASHROCKET_DIR/$1"
}
if [ -n "$BASH_VERSION" ]; then
_hcd()
{
local cur projects
[ -r "$HASHROCKET_DIR" ] || return 0
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
projects=$(\ls "$HASHROCKET_DIR")
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen -o filenames -W "$projects" $cur) )
fi
return 0
}
complete -F _hcd hcd
elif [ -n "$ZSH_VERSION" ]; then
#compdef '_files -W "$HASHROCKET_DIR"' hcd
compctl -/ -W "$HASHROCKET_DIR" hcd
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment