Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Topic/display opts #5

Closed
wants to merge 2 commits into from

2 participants

@thge

Hello,

I added two options to git-prompt. Feel free to include them in your project if you like them.

  • count_only : instead of displaying untracked/added/changed filenames only display count of untracked/added/changed files
  • rawhex_len: for git display rawhex_len characters of the revision id; using 0 as len hides the rawhex id

Thanks for your great work,

Thomas

@lvv
Owner
lvv commented

Thank for your contribution.
Applied.

@lvv lvv closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 8 deletions.
  1. +2 −1  git-prompt.conf
  2. +19 −7 git-prompt.sh
View
3  git-prompt.conf
@@ -10,7 +10,8 @@
# 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
View
26 git-prompt.sh
@@ -55,6 +55,8 @@
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
@@ -482,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}
@@ -510,7 +516,7 @@ parse_git_status() {
fi
#branch="<$branch>"
fi
- vcs_info="$branch$white=$rawhex"
+ vcs_info="$branch$rawhex"
fi
}
@@ -566,9 +572,15 @@ parse_vcs_status() {
### file list
unset file_list
- [[ ${added_files[0]} ]] && file_list+=" "$added_vcs_color${added_files[@]}
- [[ ${modified_files[0]} ]] && file_list+=" "$modified_vcs_color${modified_files[@]}
- [[ ${untracked_files[0]} ]] && file_list+=" "$untracked_vcs_color${untracked_files[@]}
+ if [[ $count_only = "on" ]] ; then
+ [[ ${added_files[0]} ]] && file_list+=" "${added_vcs_color}+${#added_files[@]}
+ [[ ${modified_files[0]} ]] && file_list+=" "${modified_vcs_color}*${#modified_files[@]}
+ [[ ${untracked_files[0]} ]] && file_list+=" "${untracked_vcs_color}?${#untracked_files[@]}
+ else
+ [[ ${added_files[0]} ]] && file_list+=" "$added_vcs_color${added_files[@]}
+ [[ ${modified_files[0]} ]] && file_list+=" "$modified_vcs_color${modified_files[@]}
+ [[ ${untracked_files[0]} ]] && file_list+=" "$untracked_vcs_color${untracked_files[@]}
+ fi
[[ ${vim_files} ]] && file_list+=" "${RED}vim:${vim_files}
file_list=${file_list:+:$file_list}
Something went wrong with that request. Please try again.