From 63c16da0da3e9b0cdc3fb6f9cd3031dc2297a09c Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 15 Aug 2023 15:26:23 +0200 Subject: [.zshrc] refactored git_parse_remote use cut instead of sed to get the state of the remote, now you could use this command: git branch -v 2> /dev/null | sed '/^*/!d;s/^[^[]*\[\([^ ]*\).*$/\1/' but at this point, it feels more like intellectual masturbation. --- config/essentials/zsh/.zshrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'config/essentials') diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 0665533..769c805 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -121,13 +121,13 @@ RPROMPT='%F{blue}$(parse_git_remote)%f%F{red}$(parse_git_status)%f%F{green}$(par setopt prompt_subst parse_git_remote() { - b="$(git branch -v 2> /dev/null | grep "^*" | sed 's/.\+\[\([^ ]\+\).*$/\1/')" + b="$(git branch -v 2>/dev/null | grep "^*" | cut -f2 -d'[' | cut -f1 -d' ')" if [ "$b" = "behind" ] then - echo -n "↓ " + printf "↓ " elif [ "$b" = "ahead" ] then - echo -n "↑ " + printf "↑ " fi } parse_git_branch() { -- cgit v1.2.3