diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2015-11-25 02:27:07 +0300 |
---|---|---|
committer | Ben Hilburn <bhilburn@gmail.com> | 2015-11-25 02:27:07 +0300 |
commit | 3fea92369f11797077f7a92468814ab1ee0238c3 (patch) | |
tree | a9ca3c6f43e4f2b08b76a7910f5a9a3b2e5a1774 /powerlevel9k.zsh-theme | |
parent | 08a3b49d735b8a0192138085880a47ed89d94971 (diff) | |
parent | df51db14129bc8fb1fa90f9e8aa3ab653fbe247a (diff) |
Merge pull request #153 from Tritlo/custom_string
Adding a segment that can execute a custom command.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 122dac10..12659e5e 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -208,6 +208,15 @@ prompt_aws() { fi } +# Custom: a way for the user to specify custom commands to run, +# and display the output of. +# +prompt_custom() { + local command=POWERLEVEL9K_CUSTOM_$2:u + + "$1_prompt_segment" "${0}_${2:u}" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$(eval ${(P)command})" +} + prompt_battery() { icons[BATTERY_ICON]=$'\UE894' # set default values of not specified in shell @@ -680,7 +689,13 @@ build_left_prompt() { defined POWERLEVEL9K_LEFT_PROMPT_ELEMENTS || POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) for element in "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[@]}"; do - "prompt_$element" "left" + # Check if it is a custom command, otherwise interpet it as + # a prompt. + if [[ $element[0,7] =~ "custom_" ]]; then + "prompt_custom" "left" $element[8,-1] + else + "prompt_$element" "left" + fi done left_prompt_end @@ -691,7 +706,13 @@ build_right_prompt() { defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time) for element in "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]}"; do - "prompt_$element" "right" + # Check if it is a custom command, otherwise interpet it as + # a prompt. + if [[ $element[0,7] =~ "custom_" ]]; then + "prompt_custom" "right" $element[8,-1] + else + "prompt_$element" "right" + fi done } |