summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme47
1 files changed, 37 insertions, 10 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 595b233d..2870802b 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() {
# The battery can have different states.
# Default is "unknown"
@@ -333,13 +342,20 @@ prompt_dir() {
fi
- "$1_prompt_segment" "$0" "blue" "$DEFAULT_COLOR" "$(print_icon 'HOME_ICON')$current_path"
+ local current_icon=''
+ if [[ $(print -P "%~") == '~'* ]]; then
+ current_icon=$(print_icon 'HOME_ICON')
+ else
+ current_icon=$(print_icon 'FOLDER_ICON')
+ fi
+
+ "$1_prompt_segment" "$0" "blue" "$DEFAULT_COLOR" "$current_icon$current_path"
}
# GO-prompt
prompt_go_version() {
local go_version
- go_version=$(go version 2>&1 | grep -oe "^go[0-9.]*")
+ go_version=$(go version 2>&1 | sed -E "s/.*(go[0-9.]*).*/\1/")
if [[ -n "$go_version" ]]; then
"$1_prompt_segment" "$0" "green" "255" "$go_version"
@@ -417,11 +433,10 @@ prompt_load() {
# Node version
prompt_node_version() {
- local nvm_prompt
- nvm_prompt=$(node -v 2>/dev/null)
- [[ -z "${nvm_prompt}" ]] && return
+ local node_version=$(node -v 2>/dev/null)
+ [[ -z "${node_version}" ]] && return
- "$1_prompt_segment" "$0" "green" "white" "${nvm_prompt:1} $(print_icon 'NODE_ICON')"
+ "$1_prompt_segment" "$0" "green" "white" "${node_version:1} $(print_icon 'NODE_ICON')"
}
# print a little OS icon
@@ -490,8 +505,8 @@ prompt_nvm() {
local nvm_default=$(cat $NVM_DIR/alias/default)
[[ -z "${node_version}" ]] && return
[[ "$node_version" =~ "$nvm_default" ]] && return
- NODE_ICON=$'\u2B22' # ⬢
- $1_prompt_segment "$0" "green" "011" "${node_version:1} $NODE_ICON"
+
+ $1_prompt_segment "$0" "green" "011" "${node_version:1} $(print_icon 'NODE_ICON')"
}
# rbenv information
@@ -703,7 +718,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
@@ -714,7 +735,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
}