From: Samir Benmendil Date: Fri, 11 Mar 2022 08:32:25 +0000 (+0000) Subject: zsh/prompt: print upstream information X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/7e2697fad1565feccb27083425a8464c0d01fcf1?ds=sidebyside zsh/prompt: print upstream information --- diff --git a/zsh/lib/prompt.zsh b/zsh/lib/prompt.zsh index 56d702b..9789ed7 100644 --- a/zsh/lib/prompt.zsh +++ b/zsh/lib/prompt.zsh @@ -51,6 +51,7 @@ git_prompt_status() { if [[ "$line" == \#\ * ]]; then [[ "$line" =~ '# branch.oid ([0-9a-f]+)' ]] && oid=$match[1] [[ "$line" =~ '# branch.head (.*)' ]] && head=$match[1] + [[ "$line" =~ '# branch.upstream (.*)' ]] && upstream=$match[1] [[ "$line" =~ '# branch.ab \+([0-9]+) -([0-9]+)' ]] && ahead=$match[1] && behind=$match[2] else # Count added, deleted, modified, renamed, unmerged, untracked, dirty. @@ -79,6 +80,7 @@ git_prompt_status() { # Format upstream local upstream_str + [[ -z "$upstream" ]] && upstream_str+="%{$fg[blue]%} Ɇ" (( ahead > 0 )) && upstream_str+="%{$fg[blue]%} >$ahead" (( behind > 0 )) && upstream_str+="%{$fg[blue]%} <$behind" git_status+="$upstream_str"