Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
.bashrc alias for changing into project directory (includes TAB completion)
function _project_list ()
{
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
PROJECTS=$(ls -d ~/projects/*/ ~/projects/*/*/ | xargs basename)
COMPREPLY=( $(compgen -W "$PROJECTS" -- ${cur}) )
return 0
}
alias prj='CDPATH=~/projects/:~/projects/skunk/:~/projects/personal/:~/projects/codeflux/ cd "$@"'
complete -F _project_list pro
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.