Skip to content

Instantly share code, notes, and snippets.

@jamessanders
Created December 9, 2010 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jamessanders/734330 to your computer and use it in GitHub Desktop.
Save jamessanders/734330 to your computer and use it in GitHub Desktop.
change directory to the base of your project by looking for '.git'
# change directory to the base of your project
# Your project base is the directory that contains
# either _darcs or .git
# to use as a command add to .zshrc or .bashrc
# alias base='source <path/to/base.sh>
CUR=$(pwd);
while [ ! "$CUR" = "/" ]
do
CUR=$(dirname "$CUR");
([ -d "$CUR/.git" ] || [ -d "$CUR/_darcs" ]) && echo "Changing directory to $CUR" && cd "$CUR" && break
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment