X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=rc%2Ffunctions;h=47db2ca93b40eaea7afde1f97179a5f011b3c673;hb=8a384ea1c4e9c00a0e02a6fdf995529421f5ba82;hp=18012885c8c281113734f72fba299e1a42b3768d;hpb=4485a622887eafc6174b305983301aa6ea46d4c9;p=clearscm.git diff --git a/rc/functions b/rc/functions index 1801288..47db2ca 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,8 +54,8 @@ function title_bar { fi # Add GIT info if available - if [ -d .git ]; then - current_dir="git: $(git branch | sed -n -e 's/^\* \(.*\)/\1/p') $current_dir" + if in_git_repo; then + current_dir="$current_dir [git: $(git branch | sed -n -e 's/^\* \(.*\)/\1/p')]" fi if [ "$TERM" = "hpterm" -o \