From aa36d147eb7d2525c08574c303b3c52d58c20c64 Mon Sep 17 00:00:00 2001 From: "Achim D. Brucker" Date: Mon, 3 Jul 2017 22:30:13 +0100 Subject: [PATCH] Added basic prompt rendering. --- themes/logicalhacking.zsh-theme | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/themes/logicalhacking.zsh-theme b/themes/logicalhacking.zsh-theme index 12af6a9..3ca650c 100755 --- a/themes/logicalhacking.zsh-theme +++ b/themes/logicalhacking.zsh-theme @@ -46,4 +46,32 @@ promptpwd() { PL_LARRW=$'\ue0b3' #  } +# Drawing of segments +CURRENT_BG='NONE' +# Begin a segment +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " + else + echo -n "%{$bg%}%{$fg%} " + fi + CURRENT_BG=$1 + [[ -n $3 ]] && echo -n $3 +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + echo -n "%{%k%}" + fi + echo -n "%{%f%}" + CURRENT_BG='' +}