Created
October 1, 2013 20:31
-
-
Save fernandoflorez/6784625 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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