Skip to content

Instantly share code, notes, and snippets.

@jgwhite
Created December 6, 2013 10:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgwhite/7821484 to your computer and use it in GitHub Desktop.
Save jgwhite/7821484 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
function p() {
PROJECT_PATH=~/Sites
results=(`find $PROJECT_PATH -type d -maxdepth 3 -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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment