From 69dd8e61c6640861e04fcdacf9d7487bc0a8b4fd Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Mon, 23 Aug 2021 15:19:48 +0100 Subject: [PATCH] ZSH: checks for project in prompt --- shells/zsh/includes/promptconfig.zsh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/shells/zsh/includes/promptconfig.zsh b/shells/zsh/includes/promptconfig.zsh index 20378ca5..1529e985 100644 --- a/shells/zsh/includes/promptconfig.zsh +++ b/shells/zsh/includes/promptconfig.zsh @@ -91,6 +91,7 @@ prompt_dir(){ } function prompt_project() { + type -p project > /dev/null || return # Prints the current project and a recording symbol if appropriate local parent_process="$(ps -ocommand -p $PPID | grep -v 'COMMAND' | cut -d' ' -f1)" local current_project_full="$(project current --path)" @@ -169,6 +170,7 @@ prompt_last_exit_code() { prompt_email(){ type -p notmuch > /dev/null || return 0 + [ -n "$(project current)" ] && return 0 unread="$(notmuch count "tag:unread")" if [ "$unread" -gt 0 ]; then echo "🖂 $unread" @@ -207,12 +209,16 @@ draw_segment(){ local foreground="" local ret="" if [ -n "$contents" ]; then - background="$(echo "$output" | sed -n '2p')" - foreground="$(echo "$output" | sed -n '3p')" - if [ -n "$previousBackground" ]; then - ret=" $(seperator $previousBackground $background)" + if [ -n "$NO_COLOR" ]; then + ret=" $(seperator white black) $contents" + else + background="$(echo "$output" | sed -n '2p')" + foreground="$(echo "$output" | sed -n '3p')" + if [ -n "$previousBackground" ]; then + ret=" $(seperator $previousBackground $background)" + fi + ret="$ret$(focusBackgroundColor $background) $(focusForegroundColor $foreground)$contents" fi - ret="$ret$(focusBackgroundColor $background) $(focusForegroundColor $foreground)$contents" echo "$ret" echo "$background" fi