mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
added git_prompt_behind
use status for git_prompt_ahead instead of log
This commit is contained in:
parent
f8a602e6f9
commit
cf9a16efad
1 changed files with 9 additions and 1 deletions
10
lib/git.zsh
10
lib/git.zsh
|
|
@ -28,11 +28,19 @@ function parse_git_dirty() { git_parse_dirty }
|
|||
|
||||
# Checks if there are commits ahead from remote
|
||||
function git_prompt_ahead() {
|
||||
if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
|
||||
if $(git status --porcelain --branch 2> /dev/null | grep '^## .*ahead' &> /dev/null); then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if there are commits behind from remote
|
||||
function git_prompt_behind() {
|
||||
if $(git status --porcelain --branch 2> /dev/null | grep '^## .*behind' &> /dev/null); then
|
||||
echo $ZSH_THEME_GIT_PROMPT_BEHIND
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Formats prompt string for current git commit short SHA
|
||||
function git_prompt_short_sha() {
|
||||
SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue