Skip to content

Instantly share code, notes, and snippets.

@fernandoflorez
Created October 1, 2013 20:31
Show Gist options
  • Save fernandoflorez/6784625 to your computer and use it in GitHub Desktop.
Save fernandoflorez/6784625 to your computer and use it in GitHub Desktop.
function _hackon() {
local opts cur prev
opts=`ls -l $HOME/projects/ | egrep '^d' | awk '{print $9}'`
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
}
function hackon() {
if [[ "$VIRTUAL_ENV" != "" ]]; then
deactivate
fi
if [ -d "$HOME/projects/$1" ]; then
if [ -f "$HOME/projects/$1/bin/activate" ]; then
source "$HOME/projects/$1/bin/activate"
fi
if [ -d "$HOME/projects/$1/src" ]; then
cd "$HOME/projects/$1/src"
else
cd "$HOME/projects/$1"
fi
fi
}
complete -F _hackon hackon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment