Skip to content

Instantly share code, notes, and snippets.

@jek
jek / vcs.sh
Created January 6, 2011 03:09 — forked from dcolish/vcs.sh
dir=$(pwd -P)
until [ $dir = '/' ]; do
[[ -e "${dir}/.hg" ]] && vcs=hg && break
[[ -e "${dir}/.git" ]] && vcs=git && break
dir=$(dirname ${dir})
done
if [ -z $vcs ]; then
echo "error: not in a git or hg repo" 1>&2 && exit 1
else