diff options
author | romkatv <roman.perepelitsa@gmail.com> | 2019-05-29 13:38:51 +0300 |
---|---|---|
committer | romkatv <roman.perepelitsa@gmail.com> | 2019-05-29 13:38:51 +0300 |
commit | 473c5c45c3554350c4fcc3b537512fea6fa6769c (patch) | |
tree | a31427d61569795ac90fd1787e0d1cba79db8338 | |
parent | 8b8743c8edc548981274184cfc922757e99df0ea (diff) |
don't invoke custom prompt command if it doesn't resolve
-rwxr-xr-x | powerlevel9k.zsh-theme | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 5452441e..1d0e43b3 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -697,14 +697,11 @@ prompt_custom() { local segment_name="${3:u}" # Get content of custom segment local command="POWERLEVEL9K_CUSTOM_${segment_name}" - local segment_content="$(eval ${(P)command})" - # Note: this would be a better implementation. I'm keeping the old one in case anyone - # relies on its quirks. - # local segment_content=$("${(@Q)${(z)${(P)command}}}") - - if [[ -n $segment_content ]]; then - "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "CUSTOM_${segment_name}_ICON" 0 '' "$segment_content" - fi + local -a cmd=("${(@Q)${(z)${(P):-POWERLEVEL9K_CUSTOM_${segment_name}}}}") + whence $cmd[1] &>/dev/null || return + local content=$("$cmd[@]") + [[ -n $content ]] || return + "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "CUSTOM_${segment_name}_ICON" 0 '' "$content" } ################################################################ |