From: andrew Date: Fri, 2 Aug 2013 19:47:13 +0000 (-0700) Subject: Added in_git_repo function X-Git-Url: https://defaria.com/gitweb/?a=commitdiff_plain;h=1d922ee420e3465e6a129aafb19ae20f2609dcde;hp=4485a622887eafc6174b305983301aa6ea46d4c9;p=clearscm.git Added in_git_repo function --- diff --git a/rc/functions b/rc/functions index 1801288..c27274b 100644 --- a/rc/functions +++ b/rc/functions @@ -17,6 +17,21 @@ CR=$(echo "\015") view_name= +function in_git_repo { + pwd=$PWD + + while [ "$pwd" != "/" ]; do + if [ -d "$pwd/.git" ]; then + true; + return; + fi + + pwd=$(dirname $pwd) + done + + false +} # in_git_repo + # Function to set the title bar. Works on the terminal emulators listed. function title_bar { prefix="$@" @@ -39,7 +54,7 @@ function title_bar { fi # Add GIT info if available - if [ -d .git ]; then + if in_git_repo; then current_dir="git: $(git branch | sed -n -e 's/^\* \(.*\)/\1/p') $current_dir" fi