Skip to content

Commit

Permalink
Close sindresorhusGH-67: provide arrows for push and pull.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Dahan authored and sindresorhus committed May 29, 2014
1 parent de623b5 commit 1ec0c5c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pure.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ prompt_pure_precmd() {
# check check if there is anything to pull
command git fetch &>/dev/null &&
# check if there is an upstream configured for this branch
command git rev-parse --abbrev-ref @'{u}' &>/dev/null &&
(( $(command git rev-list --right-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) &&
# some crazy ansi magic to inject the symbol into the previous line
print -Pn "\e7\e[A\e[1G\e[`prompt_pure_string_length $prompt_pure_preprompt`C%F{cyan}⇣%f\e8"
command git rev-parse --abbrev-ref @'{u}' &>/dev/null && {
local arrows=''
(( $(command git rev-list --right-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) && arrows=''
(( $(command git rev-list --left-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) && arrows+=''
print -Pn "\e7\e[A\e[1G\e[`prompt_pure_string_length $prompt_pure_preprompt`C%F{cyan}${arrows}%f\e8"
}
} &!

# reset value since `preexec` isn't always triggered
Expand Down

0 comments on commit 1ec0c5c

Please sign in to comment.