Skip to content

Instantly share code, notes, and snippets.

@rcoder
Forked from dcolish/vcs.sh
Created January 6, 2011 00:15
Show Gist options
  • Save rcoder/767281 to your computer and use it in GitHub Desktop.
Save rcoder/767281 to your computer and use it in GitHub Desktop.
GIT="`which git`"
HG="`which hg`"
function checkvcs() {
base=$1
if [[ -d "${base}/.git" ]]; then
VCS="$GIT"
elif [[ -d "${base}/.hg" ]]; then
VCS="$HG"
else
if [[ "${base}" = "/" ]]; then
echo "No git or hg repo found!"
exit -1
fi
checkvcs "`dirname ${base}`"
fi
}
checkvcs "`pwd`/$1"
CMD="$VCS $@"
exec $CMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment