From 631986f76a40d8f83e85585f489fad5d450a0851 Mon Sep 17 00:00:00 2001 From: fbt Date: Thu, 9 Nov 2017 16:10:14 +0300 Subject: [PATCH] typo and git ahead info Signed-off-by: fbt --- homedir/.config/zsh.d/modules/prompt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/homedir/.config/zsh.d/modules/prompt b/homedir/.config/zsh.d/modules/prompt index 9489236..5c1da0c 100644 --- a/homedir/.config/zsh.d/modules/prompt +++ b/homedir/.config/zsh.d/modules/prompt @@ -51,7 +51,7 @@ precmd.is_git_repo() { if [[ -r "$_pwd/.git/HEAD" ]]; then return 0 else - _pwd=${pwd%/*} + _pwd=${_pwd%/*} fi done @@ -72,6 +72,14 @@ precmd.git() { done < <(git status --porcelain -bu 2>/dev/null) git_branch_name=${git_branch_info%%...*} + [[ $git_branch_info =~ ahead\ ([0-9]+) ]] && git_ahead=$match[1] + + git_status_colour='green' + + (( git_ahead )) && { + git_status_short+='a' + git_status_colour='yellow' + } (( git_unstaged )) && { git_status_short+='c' @@ -84,8 +92,6 @@ precmd.git() { } git_status_short=${git_status_short:-"ok"} - git_status_colour=${git_status_colour:-"green"} - git_prompt_msg="(%F{cyan}$git_branch_name%f[%F{$git_status_colour}${git_status_short}%f]) " printf '%s' $git_prompt_msg