diff --git a/themes/gnzh.zsh-theme b/themes/gnzh.zsh-theme index 3c6b8a409..e6031ecb7 100644 --- a/themes/gnzh.zsh-theme +++ b/themes/gnzh.zsh-theme @@ -31,7 +31,34 @@ else eval PR_HOST='${PR_GREEN}%M${PR_NO_COLOR}' # no SSH fi -local return_code="%(?..%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})" +set-return-code() { + typeset -g return_code="" + if [[ $__prompt_status != 0 ]]; then + return_code="%{$PR_RED%}$__prompt_status ↵%{$PR_NO_COLOR%}" + fi +} + +set-rps1() { + local mode='' + if [[ $KEYMAP = vicmd ]]; then + mode='%{$PR_RED%}[CMD]%{$PR_NO_COLOR%}' + fi + RPS1="${return_code} ${mode}" + zle reset-prompt +} + +zle-line-init() { + typeset -g __prompt_status="$?" + set-return-code + set-rps1 +} + +zle-keymap-select() { + set-rps1 +} + +zle -N zle-keymap-select +zle -N zle-line-init local user_host='${PR_USER}${PR_CYAN}@${PR_HOST}' local current_dir='%{$PR_BOLD$PR_BLUE%}%~%{$PR_NO_COLOR%}'