Created
March 16, 2018 16:48
-
-
Save pop/3b8cb9842e169fb46fb840fb612fa8b0 to your computer and use it in GitHub Desktop.
workon
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
#!/bin/sh | |
# Put this script in your path. | |
# Add this line to your .bashrc: | |
# alias workon='. workon.sh' | |
PROJECTS_DIR="${PROJECTS_DIR:-$HOME/Source}" | |
DEPTH="${DEPTH:-6}" | |
goto_dir () { | |
d=`find $PROJECTS_DIR -maxdepth $DEPTH -name $1` | |
if [ ! -z $d ]; then | |
cd $d | |
else | |
return 1 | |
fi | |
} | |
checkout_branch () { | |
git checkout $1 | |
} | |
if [ "$#" -eq 1 ]; then | |
goto_dir $1 | |
elif [ "$#" -eq 2 ]; then | |
goto_dir $1 | |
checkout_branch $2 | |
else | |
echo 'Usage: workon <project> [branch]' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment