X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=rc%2Ffunctions;h=458a69bbb653735a5b45e44b4c8252ff762cb49e;hb=000f1f238f1e39a2ae273837e3c54d8eae0d0efe;hp=c27274bfca82f05808d094b91ced22095fea0175;hpb=8589fc0b109a7d29ea6a72cf73c4b8c27e063149;p=clearscm.git diff --git a/rc/functions b/rc/functions index c27274b..458a69b 100644 --- a/rc/functions +++ b/rc/functions @@ -17,24 +17,15 @@ 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 { + if [ $# -gt 1 ]; then + ROOT=shift + ROOT="${NORMAL}\($ROOT\)" + fi + prefix="$@" + # Change $HOME -> ~ if [ "${PWD#$HOME*}" != "$PWD" ]; then current_dir="~${PWD#$HOME*}" @@ -55,7 +46,7 @@ function title_bar { # Add GIT info if available if in_git_repo; then - current_dir="git: $(git branch | sed -n -e 's/^\* \(.*\)/\1/p') $current_dir" + current_dir="$current_dir [git: $(git branch | sed -n -e 's/^\* \(.*\)/\1/p')]" fi if [ "$TERM" = "hpterm" -o \ @@ -68,7 +59,7 @@ function title_bar { string=$(echo "${SYSNAME##*:}:$@") echo -n "${ESC}]2;$string\007" elif [ "$TERM" = "cygwin" -o "$TERM" = "vt100" -o "$TERM" = "xterm" ]; then - PS1="\[\e]0;$prefix$current_dir\a\e[01;33m\]$SYSNAME:\[\e[0m\]" + PS1="\[\e]0;$prefix$current_dir\a$ROOT\e[01;33m\]$SYSNAME:\[\e[0m\]" fi } # title_bar @@ -111,7 +102,7 @@ function set_title { view_name="" title_bar "$ROOT" else - title_bar "${ROOT}View: $view_name: " + title_bar "$ROOT" "View: $view_name: " fi icon_name "${SYSNAME##*:}"