From eda662402aeca8918f461a1474891a5921bc879d Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 2 Mar 2023 17:41:19 +0100 Subject: added git remote status to RPROMPT --- config/zshrc/.zshrc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'config/zshrc') diff --git a/config/zshrc/.zshrc b/config/zshrc/.zshrc index c54e637..1a96877 100644 --- a/config/zshrc/.zshrc +++ b/config/zshrc/.zshrc @@ -81,9 +81,19 @@ add-zsh-hook -Uz precmd rehash_precmd # prompt PS1=' %B%(#.%F{1}.%F{13})[%n%b%f@%B%F{6}%m]%b%f %3~ ' -RPROMPT='%F{red}$(parse_git_status)%f%F{green}$(parse_git_branch)%f%(?.. %?)' +RPROMPT='%F{red}$(parse_git_remote)$(parse_git_status)%f%F{green}$(parse_git_branch)%f%(?.. %?)' setopt prompt_subst +parse_git_remote() { + b="$(git branch -vv 2>/dev/null | grep "^*" | sed 's/^.\+: \([^ ]\+\) .\+$/\1/')" + if [ "$b" = "behind" ] + then + echo -n "v " + elif [ "$b" = "ahead" ] + then + echo -n "^ " + fi +} parse_git_branch() { git symbolic-ref --short HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null } -- cgit v1.2.3