mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
More detailed git prompt information.
Possibility to also display if a branch is behind, has diverged or is up-to-date. Also changed the implementation to use git-rev-list which is a bit easier than git-log.
This commit is contained in:
parent
8910f5deca
commit
303fb7286c
1 changed files with 10 additions and 2 deletions
12
lib/git.zsh
12
lib/git.zsh
|
|
@ -22,8 +22,16 @@ parse_git_dirty() {
|
|||
|
||||
# Checks if there are commits ahead from remote
|
||||
function git_prompt_ahead() {
|
||||
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
ahead=$(git rev-list origin/$(current_branch)..HEAD -- 2> /dev/null)
|
||||
behind=$(git rev-list HEAD..origin/$(current_branch) -- 2> /dev/null)
|
||||
if [[ -n $ahead && -n $behind ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIVERGED"
|
||||
elif [[ -n $ahead ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
elif [[ -n $behind ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_UPTODATE"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue