From 5f06a3ca53faf20a75ae672b89ba201ff7cf3877 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 25 Jan 2024 21:57:26 +0100 Subject: zsh Refactor multiple files and use zap --- config/essentials/zsh/prompt.zsh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 config/essentials/zsh/prompt.zsh (limited to 'config/essentials/zsh/prompt.zsh') diff --git a/config/essentials/zsh/prompt.zsh b/config/essentials/zsh/prompt.zsh new file mode 100644 index 0000000..5364401 --- /dev/null +++ b/config/essentials/zsh/prompt.zsh @@ -0,0 +1,16 @@ +# prompt +# PS1=' %K{16}%B%(#.%F{1}.%F{13})%n%b%f@%B%F{6}%m%b%f %3~%k ' +# RPROMPT='%F{blue}$(parse_git_remote)%f%F{red}$(parse_git_status)%f%F{green}$(parse_git_branch)%f%(?.. %?)' + +setopt prompt_subst +parse_git_remote() { + git branch -v 2> /dev/null | + awk -F '[][]' '/^\*/ {print $2}' | + sed 's/ahead/↑ /;s/behind/↓ /;s/[^↓↑]*/ /g' +} +parse_git_branch() { + git symbolic-ref --short HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null +} +parse_git_status() { + git status --short 2> /dev/null | head -n1 | awk '{print $1 " "}' +} \ No newline at end of file -- cgit v1.2.3