Skip to content

Instantly share code, notes, and snippets.

@mloberg mloberg/gist:3084643
Created Jul 10, 2012

Embed
What would you like to do?
Find and cd to projects.
#!/usr/bin/env bash
# Add or source this from .bash_profile/.bashrc
# usage: project project_name
PROJECT_DIR="~/Code"
project() {
PROJECTS=( $(find $PROJECT_DIR -type d -iname "$1") )
if [[ "${#PROJECTS[@]}" -gt 1 ]]; then
echo "Not sure which project you're talking about."
i=0
for proj in "${PROJECTS[@]}"; do
echo "$i: ${proj}"
i=$(expr $i + 1)
done
read -p "Project: " p
cd "${PROJECTS[$p]}"
elif [[ "${#PROJECTS[@]}" -le 0 ]]; then
echo "Unknown project."
return 1
else
cd "${PROJECTS[0]}"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.