diff --git a/README.md b/README.md index 8127a5d6..e054dd7c 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,8 @@ Add to the `~/.bashrc`: # GIT_PROMPT_SHOW_UPSTREAM=1 # uncomment to show upstream tracking branch # GIT_PROMPT_SHOW_UNTRACKED_FILES=all # can be no, normal or all; determines counting of untracked files + + # GIT_PROMPT_SHOW_CHANGED_FILES_COUNT=0 # uncomment to avoid printing the number of changed files # GIT_PROMPT_STATUS_COMMAND=gitstatus_pre-1.7.10.sh # uncomment to support Git older than 1.7.10 diff --git a/gitprompt.sh b/gitprompt.sh index 492cd936..23f7bc36 100755 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -470,6 +470,12 @@ function updatePrompt() { export __GIT_PROMPT_SHOW_UNTRACKED_FILES=${GIT_PROMPT_SHOW_UNTRACKED_FILES} fi + if [ -z "${GIT_PROMPT_SHOW_CHANGED_FILES_COUNT}" ]; then + export __GIT_PROMPT_SHOW_CHANGED_FILES_COUNT=1 + else + export __GIT_PROMPT_SHOW_CHANGED_FILES_COUNT=${GIT_PROMPT_SHOW_CHANGED_FILES_COUNT} + fi + local GIT_INDEX_PRIVATE="$(createPrivateIndex)" #important to define GIT_INDEX_FILE as local: This way it only affects this function (and below) - even with the export afterwards local GIT_INDEX_FILE @@ -513,7 +519,7 @@ function updatePrompt() { v="\$GIT_$1 $2" fi if eval "test $v" ; then - if [[ $# -lt 2 || "$3" != '-' ]]; then + if [[ $# -lt 2 || "$3" != '-' ]] && [[ "x$__GIT_PROMPT_SHOW_CHANGED_FILES_COUNT" == "x1" || "x$1" == "xREMOTE" ]]; then __add_status "\$GIT_PROMPT_$1\$GIT_$1\$ResetColor" else __add_status "\$GIT_PROMPT_$1\$ResetColor"