Skip to content

Instantly share code, notes, and snippets.

@jgwhite
Created June 15, 2011 14:37
Show Gist options
  • Select an option

  • Save jgwhite/1027247 to your computer and use it in GitHub Desktop.

Select an option

Save jgwhite/1027247 to your computer and use it in GitHub Desktop.
Jump-to-project command line tool

Type p proj to jump to ~/Sites/my_project

Type p js to bring up a list of projects whose names contain 'js'

#!/usr/bin/env bash
PROJECT_PATH=~/Sites
function p() {
results=(`find $PROJECT_PATH -type d -maxdepth 2 -iname "*$1*"`)
count=${#results[@]}
if [ $count -gt 1 ]; then
echo ""
i=0
while [ $i -lt $count ]; do
let num=$i+1
echo "[$num] ${results[$i]}"
let i+=1
done
echo ""
echo -n "Which project would you like to open [1]: "
read choice
if [ ! -n "$choice" ]; then
let num=0
else
let num=$choice-1
fi
echo ""
cd ${results[$num]}
elif [ $results ]; then
project=${results[0]}
cd $project
else
echo "Project '$1' not found"
fi
}
[[ $- == *i* ]] && . /path/to/jump_to_project.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment