From 47b70d6de513aaa8f32911c92f1f3508c76c6f53 Mon Sep 17 00:00:00 2001 From: Thomas Geffert Date: Wed, 2 Mar 2011 19:12:15 +0800 Subject: added rawhex_len option to set length of displayed git revision id --- git-prompt.conf | 1 + git-prompt.sh | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/git-prompt.conf b/git-prompt.conf index 414c3d6..c136964 100644 --- a/git-prompt.conf +++ b/git-prompt.conf @@ -11,6 +11,7 @@ # error_bell=off # sound terminal bell when command return code is not zero. (use setterm to set pitch and duration) # max_file_list_length=100 # in characters # count_only=off # off - display file list; on - display file count +# rawhex_len=6 # length of git rawhex revision id display (use 0 to hide it) ############################################################ MODULES diff --git a/git-prompt.sh b/git-prompt.sh index e4eb9f6..81bca6c 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -56,6 +56,7 @@ max_file_list_length=${max_file_list_length:-100} upcase_hostname=${upcase_hostname:-on} count_only=${count_only:-off} + rawhex_len=${rawhex_len:-6} aj_max=20 @@ -483,9 +484,13 @@ parse_git_status() { #### GET GIT HEX-REVISION - rawhex=`git rev-parse HEAD 2>/dev/null` - rawhex=${rawhex/HEAD/} - rawhex=${rawhex:0:6} + if [[ $rawhex_len -gt 0 ]] ; then + rawhex=`git rev-parse HEAD 2>/dev/null` + rawhex=${rawhex/HEAD/} + rawhex="$white=${rawhex:0:$rawhex_len}" + else + rawhex="" + fi #### branch branch=${branch/master/M} @@ -511,7 +516,7 @@ parse_git_status() { fi #branch="<$branch>" fi - vcs_info="$branch$white=$rawhex" + vcs_info="$branch$rawhex" fi } -- cgit v1.2.3