Skip to content

Instantly share code, notes, and snippets.

@jbr
Created October 27, 2009 21:42
Show Gist options
  • Save jbr/219984 to your computer and use it in GitHub Desktop.
Save jbr/219984 to your computer and use it in GitHub Desktop.
How I switch between projects

Stick this in the bottom of ~/.profile & update PROJECT_BASE
Assuming you have a bunch of projects in PROJECT_BASE, you can do

bash> project my_project_name

You’ll now be in $PROJECT_BASE/my_project_name
Any new bash sessions you start will begin in that directory, which makes opening new tabs really convenient.
You can also just do

bash> project

to go to the most recently active project.

You can also do

bash> project list

to get a recency-ordered list of projects.

Enjoy!

function project {
PROJECT_BASE=~/code
if [ "$1" ]; then
PROJECT=$PROJECT_BASE/$1
if [ -d $PROJECT ]; then
touch $PROJECT_BASE/$1
elif [ $1 = "list" ]; then
echo
echo "Projects"
echo
ls -t1 $PROJECT_BASE
return 0
else
echo "No project $1"
return -1
fi
fi
cd $PROJECT_BASE/`ls -t1 $PROJECT_BASE|head -n1`
}
project
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment