aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md22
-rw-r--r--README.md11
-rwxr-xr-xpowerlevel9k.zsh-theme57
3 files changed, 63 insertions, 27 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 65a04de0..8cfaa1d6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-## v0.3.0 (next)
+## v0.3.0
### Introduced "visual identifiers" to the segments
@@ -11,11 +11,31 @@ You can now merge segments together by suffixing the segment name with "_joined"
For Developers: Be aware that the order of parameters in left/right_prompt_segment
has changed. Now a boolean parameter must be set as second parameter (true if joined).
+### `dir` changes
+
+This segment now has "state", which means you now can change the colors seperatly
+depending if you are in your homefolder or not.
+Your variables for that should now look like:
+```zsh
+POWERLEVEL9K_DIR_HOME_BACKGROUND='green'
+POWERLEVEL9K_DIR_HOME_FOREGROUND='cyan'
+POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='red'
+POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='yellow'
+```
+
### `status` changes
The `status` segment was split up into three segments. `background_jobs` prints
an icon if there are background jobs. `root_indicator` prints an icon if the user
is root. The `status` segment focuses now on the status only.
+The `status` segment also now has "state". If you want to overwrite the colors,
+you have to add the state to your variables:
+```zsh
+POWERLEVEL9K_STATUS_ERROR_BACKGROUND='green'
+POWERLEVEL9K_STATUS_ERROR_FOREGROUND='cyan'
+POWERLEVEL9K_STATUS_OK_BACKGROUND='red'
+POWERLEVEL9K_STATUS_OK_FOREGROUND='yellow'
+```
### New segment `custom_command` added
diff --git a/README.md b/README.md
index e39722b2..9a5f7b12 100644
--- a/README.md
+++ b/README.md
@@ -206,6 +206,17 @@ In each case you have to specify the length you want to shorten the directory
to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in
others whole directories.
+
+| `Compatible` | `Powerline` | `Awesome Powerline` | Situation
+|------------|-----------|-------------------|----------------------------
+| None | None | ![home icon](https://cloud.githubusercontent.com/assets/1544760/12183451/40ec4016-b58f-11e5-9b9e-74e2b2f0b8b3.png) | Within Home folder |
+| None | None | ![folder icon](https://cloud.githubusercontent.com/assets/1544760/12183452/40f79286-b58f-11e5-9b8c-ed1343a07b08.png) | Outside of home folder |
+
+To turn off these icons you could set these variables to an empty string.
+
+ POWERLEVEL9K_HOME_ICON=''
+ POWERLEVEL9K_FOLDER_ICON=''
+
##### ip
This segment shows you your current internal IP address. It tries to examine
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index edd16582..c01c9a9d 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -147,7 +147,7 @@ left_prompt_segment() {
local joined=$2
if [[ $CURRENT_BG != 'NONE' ]] && ! isSameColor "$3" "$CURRENT_BG"; then
- echo -n "%{$bg%F{$CURRENT_BG}%}"
+ echo -n "$bg%F{$CURRENT_BG}"
if [[ $joined == false ]]; then
# Middle segment
echo -n "$(print_icon 'LEFT_SEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS"
@@ -159,13 +159,13 @@ left_prompt_segment() {
# enough contrast.
local complement
[[ -n "$4" ]] && complement="$4" || complement=$DEFAULT_COLOR
- echo -n "%{$bg%F{$complement}%}"
+ echo -n "$bg%F{$complement}"
if [[ $joined == false ]]; then
echo -n "$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS"
fi
else
# First segment
- echo -n "%{$bg%}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS"
+ echo -n "${bg}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS"
fi
local visual_identifier
@@ -184,7 +184,7 @@ left_prompt_segment() {
# Print the visual identifier
echo -n "${visual_identifier}"
# Print the content of the segment, if there is any
- [[ -n "$5" ]] && echo -n "%{$fg%}${5}"
+ [[ -n "$5" ]] && echo -n "${fg}${5}"
echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}"
CURRENT_BG=$3
@@ -193,11 +193,11 @@ left_prompt_segment() {
# End the left prompt, closes the final segment.
left_prompt_end() {
if [[ -n $CURRENT_BG ]]; then
- echo -n "%{%k%F{$CURRENT_BG}%}$(print_icon 'LEFT_SEGMENT_SEPARATOR')"
+ echo -n "%k%F{$CURRENT_BG}$(print_icon 'LEFT_SEGMENT_SEPARATOR')"
else
echo -n "%k"
fi
- echo -n "%{%f%}$(print_icon 'LEFT_SEGMENT_END_SEPARATOR')"
+ echo -n "%f$(print_icon 'LEFT_SEGMENT_END_SEPARATOR')"
CURRENT_BG=''
}
@@ -258,7 +258,7 @@ right_prompt_segment() {
fi
fi
- echo -n "%{$bg%}%{$fg%}"
+ echo -n "${bg}${fg}"
# Print whitespace only if segment is not joined or first right segment
[[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]] && echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}"
@@ -289,14 +289,6 @@ prompt_aws() {
fi
}
-# The 'custom` prompt provides a way for users to invoke commands and display
-# the output in a segment.
-prompt_custom() {
- local command=POWERLEVEL9K_CUSTOM_$3:u
-
- "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$(eval ${(P)command})"
-}
-
# Segment to indicate background jobs with an icon.
prompt_background_jobs() {
if [[ $(jobs -l | wc -l) -gt 0 ]]; then
@@ -407,6 +399,14 @@ prompt_context() {
fi
}
+# The 'custom` prompt provides a way for users to invoke commands and display
+# the output in a segment.
+prompt_custom() {
+ local command=POWERLEVEL9K_CUSTOM_$3:u
+
+ "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$(eval ${(P)command})"
+}
+
# Dir: current working directory
prompt_dir() {
local current_path='%~'
@@ -492,6 +492,14 @@ prompt_ip() {
}
prompt_load() {
+ # The load segment can have three different states
+ local current_state="unknown"
+ typeset -AH load_states
+ load_states=(
+ 'critical' 'red'
+ 'warning' 'yellow'
+ 'normal' 'green'
+ )
if [[ "$OS" == "OSX" ]]; then
load_avg_5min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1)
else
@@ -502,17 +510,14 @@ prompt_load() {
load_avg_5min=${load_avg_5min//,/.}
if [[ "$load_avg_5min" -gt 10 ]]; then
- BACKGROUND_COLOR="red"
- FUNCTION_SUFFIX="_CRITICAL"
+ current_state="critical"
elif [[ "$load_avg_5min" -gt 3 ]]; then
- BACKGROUND_COLOR="yellow"
- FUNCTION_SUFFIX="_WARNING"
+ current_state="warning"
else
- BACKGROUND_COLOR="green"
- FUNCTION_SUFFIX="_NORMAL"
+ current_state="normal"
fi
- "$1_prompt_segment" "$0$FUNCTION_SUFFIX" "$2" "$BACKGROUND_COLOR" "$DEFAULT_COLOR" "$load_avg_5min" 'LOAD_ICON'
+ "$1_prompt_segment" "${0}${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg_5min" 'LOAD_ICON'
}
# Node version
@@ -639,7 +644,7 @@ prompt_rvm() {
fi
}
-# Status: (return code, root status, background jobs)
+# Status: return code if verbose, otherwise just an icon if an error occurred
set_default POWERLEVEL9K_STATUS_VERBOSE true
prompt_status() {
if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then
@@ -843,7 +848,7 @@ powerlevel9k_prepare_prompts() {
RETVAL=$?
if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then
- PROMPT="$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%{%f%b%k%}$(build_left_prompt)
+ PROMPT="$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt)
$(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')"
if [[ "$POWERLEVEL9K_RPROMPT_ON_NEWLINE" != true ]]; then
# The right prompt should be on the same line as the first line of the left
@@ -859,13 +864,13 @@ $(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')"
RPROMPT_SUFFIX=''
fi
else
- PROMPT="%{%f%b%k%}$(build_left_prompt)"
+ PROMPT="%f%b%k$(build_left_prompt)"
RPROMPT_PREFIX=''
RPROMPT_SUFFIX=''
fi
if [[ "$POWERLEVEL9K_DISABLE_RPROMPT" != true ]]; then
- RPROMPT="$RPROMPT_PREFIX%{%f%b%k%}$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX"
+ RPROMPT="$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX"
fi
}