Skip to content

Commit

Permalink
feat(ahead/behind): support independent hiding when inactive
Browse files Browse the repository at this point in the history
  • Loading branch information
olets committed May 2, 2020
1 parent 5bf6432 commit 7bd397b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ The following apply to the default prompt, and to the relevant components if use
- show the checked out branch, unless HEAD is detached in which case show the checked out commit
- dim the checked out branch or commit if the working tree is clean
- flag the checked out branch as local if it has no upstream
- hide the behind and ahead components if HEAD is detached or has no upstream
- dim the behind and/or ahead components if not behind or ahead
- show the number of commits behind and/or ahead of the upstream branch the local branch is
- show the checked out branch's upstream's remote and branch name if the remote is not `origin`
- show the checked out branch's upstream's branch name if different from the local name
- dim the stash count if zero
Expand All @@ -117,8 +116,9 @@ Customize
- the Git symbols (for branch, commit, commits behind, commits ahead, stash, assumed-unchanged count, skip-worktree count, and file)
- the default Git remote
- the "custom" component's content
- whether to display zero-count stash, assumed-unchanged, and skip-worktree components (independent of the option below)
- whether to display zero-count working tree components (independent of the option above)
- whether to display zero-count commits-ahead and commits-behind components
- whether to display zero-count stash, assumed-unchanged, and skip-worktree components
- whether to display zero-count working tree components

### Options specific to the default prompt

Expand Down Expand Up @@ -157,6 +157,7 @@ Name | Type | Description | Default
`GIT_PROMPT_KIT_LOCAL` | string | Shown if the checked-out branch has no upstream | `local`
`GIT_PROMPT_KIT_PROMPT_CHAR_NORMAL` | string | Character show at end of prompt for normal users | `%%` ***
`GIT_PROMPT_KIT_PROMPT_CHAR_ROOT` | string | Character show at end of prompt for root users | `#`
`GIT_PROMPT_KIT_SHOW_INACTIVE_AHEAD_BEHIND` | number | Show dimmed symbols for the commits behind/ahead of the upstream branch when there are none (YES if non-zero, NO if zero) | `1`
`GIT_PROMPT_KIT_SHOW_INACTIVE_CONTEXT` | number | Show dimmed Git stash, assumed-unchanged, and skip-worktree symbols? (YES if non-zero, NO if zero) | `1`
`GIT_PROMPT_KIT_SHOW_INACTIVE_STATUS` | number | Show dimmed Git status symbols? (YES if non-zero, NO if zero) | `1`
`GIT_PROMPT_KIT_USE_DEFAULT_PROMPT` | number | Use the default Git Prompt Kit prompt? (YES if non-zero, NO if zero) | `1`
Expand Down
5 changes: 3 additions & 2 deletions git-prompt-kit.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ GIT_PROMPT_KIT_NO_LINEBREAK_BEFORE_GIT_REF=${GIT_PROMPT_KIT_NO_LINEBREAK_BEFORE_
GIT_PROMPT_KIT_PROMPT_CHAR_NORMAL=${GIT_PROMPT_KIT_PROMPT_CHAR_NORMAL-%%}
GIT_PROMPT_KIT_PROMPT_CHAR_ROOT=${GIT_PROMPT_KIT_PROMPT_CHAR_ROOT-#}
GIT_PROMPT_KIT_SHOW_EXTENDED_STATUS=${GIT_PROMPT_KIT_SHOW_EXTENDED_STATUS:-1}
GIT_PROMPT_KIT_SHOW_INACTIVE_AHEAD_BEHIND=${GIT_PROMPT_KIT_SHOW_INACTIVE_AHEAD_BEHIND:-1}
GIT_PROMPT_KIT_SHOW_INACTIVE_CONTEXT=${GIT_PROMPT_KIT_SHOW_INACTIVE_CONTEXT:-1}
GIT_PROMPT_KIT_SHOW_INACTIVE_STATUS=${GIT_PROMPT_KIT_SHOW_INACTIVE_STATUS:-1}
GIT_PROMPT_KIT_USE_DEFAULT_PROMPT=${GIT_PROMPT_KIT_USE_DEFAULT_PROMPT:-1}
Expand Down Expand Up @@ -203,12 +204,12 @@ function _git_prompt_kit_update_git() {
if [[ -z $VCS_STATUS_REMOTE_BRANCH ]]; then
GIT_PROMPT_KIT_UPSTREAM+="%F{$GIT_PROMPT_KIT_COLOR_REMOTE}$GIT_PROMPT_KIT_LOCAL%F{$GIT_PROMPT_KIT_COLOR_INACTIVE}"
else
if (( GIT_PROMPT_KIT_SHOW_INACTIVE_STATUS || VCS_STATUS_COMMITS_BEHIND )); then
if (( GIT_PROMPT_KIT_SHOW_INACTIVE_AHEAD_BEHIND || VCS_STATUS_COMMITS_BEHIND )); then
(( VCS_STATUS_COMMITS_BEHIND )) && GIT_PROMPT_KIT_BEHIND+="%F{$GIT_PROMPT_KIT_COLOR_HEAD}$VCS_STATUS_COMMITS_BEHIND"
GIT_PROMPT_KIT_BEHIND+="$GIT_PROMPT_KIT_SYMBOL_BEHIND%F{$GIT_PROMPT_KIT_COLOR_INACTIVE}"
fi

if (( GIT_PROMPT_KIT_SHOW_INACTIVE_STATUS || VCS_STATUS_COMMITS_AHEAD )); then
if (( GIT_PROMPT_KIT_SHOW_INACTIVE_AHEAD_BEHIND || VCS_STATUS_COMMITS_AHEAD )); then
(( VCS_STATUS_COMMITS_AHEAD )) && GIT_PROMPT_KIT_AHEAD+="%F{$GIT_PROMPT_KIT_COLOR_REMOTE}$VCS_STATUS_COMMITS_AHEAD"
GIT_PROMPT_KIT_AHEAD+="$GIT_PROMPT_KIT_SYMBOL_AHEAD%F{$GIT_PROMPT_KIT_COLOR_INACTIVE}"
fi
Expand Down

0 comments on commit 7bd397b

Please sign in to comment.