_get_project_names(){ local cur prev base COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" local names=$(for x in `ls -d1 /Users/$USER/Projects/*`; do echo ${x/\/Users\/$USER\/Projects\//} ; done) COMPREPLY=( $(compgen -W "${names}" -- ${cur}) ) } p(){ cd /Users/$USER/Projects/$1/; } complete -F _get_project_names p
Just type p
followed by the first (few) letter(s) of your projects name, hit ->| (tab) to auto complete, hit return to go to ~/Projects/<project_name>
Credit to Edd
or use http://github.com/rupa/z