Skip to content

Instantly share code, notes, and snippets.

@wyattdanger
Forked from jamessanders/base.sh
Created December 13, 2010 16:41
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 wyattdanger/739201 to your computer and use it in GitHub Desktop.
Save wyattdanger/739201 to your computer and use it in GitHub Desktop.
# change directory to the base of your project
# Your project base is the directory that contains
# either _darcs or .git or .hg
# 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/.hg" ] || [ -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