From 0c1a5877c1ef0caf2b74af2e90eb0a1a9ca28adf Mon Sep 17 00:00:00 2001 From: Midgard <2885-Midgard@users.noreply.framagit.org> Date: Thu, 13 Jun 2019 19:42:35 +0200 Subject: [PATCH] [zsh theme] Clean up code --- midgard.zsh-theme | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/midgard.zsh-theme b/midgard.zsh-theme index 9de0d4a..be72e2d 100644 --- a/midgard.zsh-theme +++ b/midgard.zsh-theme @@ -2,24 +2,26 @@ function my_pwd { # ~ for home; keep only the last two directories - echo $(echo "$PWD" | sed -r ' + echo "$PWD" | sed -r ' s,^'"$HOME"',~,; t reset; :reset s|^~/git/my-cool-project/([^/])[^/]+/([^/]+)/|\1/\2/|; t end s|^.+/([^/]*/[^/]*)$|\1| - :end') + :end' } function my_retval { RETVAL=$? if [[ $RETVAL -eq 0 ]]; then - echo "%{$fg[yellow]%}" + echo "%{%F{yellow}%}" else - echo "%{$fg[red]%}$RETVAL " + echo "%{%F{red}%}$RETVAL " fi } -PROMPT='$(my_retval)$(my_pwd)$(git_prompt_info)$(git_prompt_status) %{$reset_color%} ' +function precmd { + PS1="$(my_retval)$(my_pwd)$(git_prompt_info)$(git_prompt_status) %{%f%} " +} ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[green]%}  " ZSH_THEME_GIT_PROMPT_SUFFIX=""