summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorMatthías Páll Gissurarson <mpg@mpg.is>2015-11-19 01:45:22 +0300
committerMatthías Páll Gissurarson <mpg@mpg.is>2015-11-22 01:11:34 +0300
commitdf51db14129bc8fb1fa90f9e8aa3ab653fbe247a (patch)
tree52f9ac343decd75ef6bb6a8ade249e9315a5dee7 /powerlevel9k.zsh-theme
parentb83cfd7515d5d6c0feaa9915f1a89a5d45a2c689 (diff)
added a segment to be able to display the result of a custom command.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme25
1 files changed, 23 insertions, 2 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index cdcb9a96..abab9d8e 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
@@ -681,7 +690,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
@@ -692,7 +707,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
}