Merge pull request #1242 from sharils/master

Add SCM_GIT_SHOW_STASH_INFO flag #914
pull/1247/head
Nils Winkler 2018-10-17 08:33:44 +02:00 committed by GitHub
commit aadba30cf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -312,6 +312,19 @@ Also, with this flag to false, Bash-it will not show the repository as dirty whe
**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always. **NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always.
### Stash item count
When `SCM_GIT_SHOW_DETAILS` is enabled, you can get the count of *stashed* items. This feature can be useful when a user has a lot of stash items.
This feature is controlled through the flag `SCM_GIT_SHOW_STASH_INFO` as follows:
Set `SCM_GIT_SHOW_STASH_INFO` to 'true' (the default value) to **show** the count of stashed items:
* `export SCM_GIT_SHOW_STASH_INFO=true`
Set `SCM_GIT_SHOW_STASH_INFO` to 'false' to **don't show** it:
* `export SCM_GIT_SHOW_STASH_INFO=false`
### Git user ### Git user
In some environments, it is useful to know the value of the current git user, which is used to mark all new commits. In some environments, it is useful to know the value of the current git user, which is used to mark all new commits.

View File

@ -32,6 +32,7 @@ SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto}
SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false} SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false}
SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false} SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false}
SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false} SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false}
SCM_GIT_SHOW_STASH_INFO=${SCM_GIT_SHOW_STASH_INFO:=true}
SCM_GIT='git' SCM_GIT='git'
SCM_GIT_CHAR='±' SCM_GIT_CHAR='±'
@ -181,9 +182,11 @@ function git_prompt_vars {
[[ "${commits_ahead}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${commits_ahead}" [[ "${commits_ahead}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${commits_ahead}"
[[ "${commits_behind}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${commits_behind}" [[ "${commits_behind}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${commits_behind}"
if [[ "${SCM_GIT_SHOW_STASH_INFO}" = "true" ]]; then
local stash_count local stash_count
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')" stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}" [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}"
fi
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
if ! _git-hide-status; then if ! _git-hide-status; then