aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateus "Doodad" Medeiros <dood.ad@outlook.com>2016-05-24 16:53:48 +0300
committerBen Hilburn <bhilburn@gmail.com>2016-07-07 20:02:16 +0300
commit20b4d2b43e91c2e347eed057acb62269d66aac25 (patch)
tree6646a16f680d174145e9fc132cf0cc43555b8b56
parent81c55b4b7465a427c4ed4aa066d1ff3612f8469d (diff)
Make prompt_custom not print the segment if empty
Currently you can't make a conditional custom segment. This changes the prompt_custom function responsible for printing custom segments so that it won't print the segment in case the content is empty. With this it becomes possible to make conditional custom prompts simply by making it not print anything when it's not supposed to be shown.
-rwxr-xr-xpowerlevel9k.zsh-theme5
1 files changed, 4 insertions, 1 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index ef6d0a5a..088a7372 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -445,8 +445,11 @@ prompt_context() {
# the output in a segment.
prompt_custom() {
local command=POWERLEVEL9K_CUSTOM_$3:u
+ local segment_content="$(eval ${(P)command})"
- "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$(eval ${(P)command})"
+ if [[ -n $segment_content ]]; then
+ "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content"
+ fi
}
# Dir: current working directory