Skip to content

Instantly share code, notes, and snippets.

@onlytracks
Created August 3, 2012 15:48
Show Gist options
  • Save onlytracks/3248894 to your computer and use it in GitHub Desktop.
Save onlytracks/3248894 to your computer and use it in GitHub Desktop.
Bash autocomplete directory names for cd alias
function cdcode() { cd $HOME/code/$@ ;}
_cdcode () { local cur; cur=${COMP_WORDS[$COMP_CWORD]}; COMPREPLY=( $( compgen -d -- $HOME/code/ | grep $cur | xargs --no-run-if-empty -l1 basename ) ); return 0; }
complete -F _cdcode cdcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment