mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Merge e2def7f1f3 into caa15548c1
This commit is contained in:
commit
c1fd0c8faa
2 changed files with 8 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
|||
# get the name of the branch we are on
|
||||
function git_prompt_info() {
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(git_prompt_ahead)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ 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
|
||||
if $(echo "$(git log $(git_current_upstream)/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,10 +54,15 @@ function current_branch() {
|
|||
echo ${ref#refs/heads/}
|
||||
}
|
||||
|
||||
function git_current_upstream(){
|
||||
local upstream=$(git config --get branch."$(current_branch)".remote) || return
|
||||
echo $upstream
|
||||
}
|
||||
|
||||
# these aliases take advantage of the previous function
|
||||
alias ggpull='git pull origin $(current_branch)'
|
||||
compdef ggpull=git
|
||||
alias ggpush='git push origin $(current_branch)'
|
||||
compdef ggpush=git
|
||||
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
|
||||
compdef ggpnp=git
|
||||
compdef ggpnp=git
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue