Created
July 5, 2012 03:41
-
-
Save mrabbitt/3051104 to your computer and use it in GitHub Desktop.
Wrapper for SourceTree "stree" command which works on any file or directory nested inside inside a Git or Mercurial repo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
getRepoRoot() | |
{ | |
local target=$1 | |
if [ -d "${target}" ] ; then | |
cd "${target}" | |
elif [ -f "${target}" ] ; then | |
cd "$(dirname ${target})" | |
fi | |
echo $(git rev-parse --show-toplevel 2>/dev/null || hg root 2>/dev/null) | |
} | |
STREE_EXE='stree' | |
if ! type "${STREE_EXE}" ; then | |
if [ -x '/Applications/SourceTree.app/Contents/Resources/stree' ] ; then | |
STREE_EXE='/Applications/SourceTree.app/Contents/Resources/stree' | |
fi | |
fi | |
repo_root_path=$(getRepoRoot "${1:-${PWD}}") | |
"$STREE_EXE" "${repo_root_path}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment