From 17c069d25ac7b24af6b5dc7ecb9597cef881f582 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 26 Aug 2017 13:59:15 -0400 Subject: [PATCH 1/5] README: Quick fix to MD formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 49863a34..c1842e3b 100644 --- a/README.md +++ b/README.md @@ -363,7 +363,7 @@ Customizations available are: | Strategy Name | Description | |---------------|-------------| |Default|Truncate whole directories from left. How many is defined by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`| -|`truncate_middle`|Truncates the middle part of a folder. E.g. you are in a folder named "~/MySuperProjects/AwesomeFiles/BoringOffice", then it will truncated to "~/MyS..cts/Awe..les/BoringOffice", if `POWERLEVEL9K_SHORTEN_DIR_LENGTH=3` is also set (controls the amount of characters to be left).| +|`truncate_middle`|Truncates the middle part of a folder. E.g. you are in a folder named `~/MySuperProjects/AwesomeFiles/BoringOffice`, then it will truncated to `~/MyS..cts/Awe..les/BoringOffice`, if `POWERLEVEL9K_SHORTEN_DIR_LENGTH=3` is also set (controls the amount of characters to be left).| |`truncate_from_right`|Just leaves the beginning of a folder name untouched. E.g. your folders will be truncated like so: "/ro../Pr../office". How many characters will be untouched is controlled by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`.| |`truncate_with_package_name`|Search for a `package.json` or `composer.json` and prints the `name` field to abbreviate the directory path. The precedence and/or files could be set by `POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)`. If you have [jq](https://stedolan.github.io/jq/) installed, it will dramatically improve the speed of this strategy.| |`truncate_with_folder_marker`|Search for a file that is specified by `POWERLEVEL9K_SHORTEN_FOLDER_MARKER` and truncate everything before that (if found, otherwise stop on $HOME and ROOT).| From c6c405955e56475cbdd9347ef259c2d4229171c4 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sun, 27 Aug 2017 12:50:22 -0400 Subject: [PATCH 2/5] README: Quick typo fix. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1842e3b..9d0ba2be 100644 --- a/README.md +++ b/README.md @@ -407,7 +407,7 @@ You can also configure the `dir` segment to show when you are in a directory wit | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_DIR_SHOW_WRITABLE`|`false`|If set to `true` and you are in a directory that you do not have write permissions for, this segment will display a lock icon and enter the `NOT_WRITABLE` state (which can be customized per [our usual process](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization). Note that this functionality is also available in a separate segment, `dir_writable`.| +|`POWERLEVEL9K_DIR_SHOW_WRITABLE`|`false`|If set to `true` and you are in a directory that you do not have write permissions for, this segment will display a lock icon and enter the `NOT_WRITABLE` state (which can be customized per [our usual process](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization)). Note that this functionality is also available in a separate segment, `dir_writable`.| ##### disk_usage From 2c388b6c809189551eab94a8a43346987fdfc330 Mon Sep 17 00:00:00 2001 From: Richard Tippl Date: Sun, 27 Aug 2017 22:42:52 +0200 Subject: [PATCH 3/5] Fix average selection in load segment. Removed duplicate code selecting which load average to use. Fixed load average selection being in OSX/BSD part of if, making it not work on non OSX/BSD systems. Optimized actually getting the load average. --- powerlevel9k.zsh-theme | 49 ++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b03a9374..5aa280c6 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -932,13 +932,14 @@ prompt_vpn_ip() { done } +set_default POWERLEVEL9K_LOAD_WHICH 5 prompt_load() { # The load segment can have three different states local current_state="unknown" + local load_select=2 + local load_avg local cores - set_default POWERLEVEL9K_LOAD_WHICH 5 - typeset -AH load_states load_states=( 'critical' 'red' @@ -946,32 +947,38 @@ prompt_load() { 'normal' 'green' ) - if [[ "$OS" == "OSX" ]] || [[ "$OS" == "BSD" ]]; then - - if [[ "$POWERLEVEL9K_LOAD_WHICH" -eq 1 ]]; then - load_avg=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 3 | sed -n 1p) - elif [[ "$POWERLEVEL9K_LOAD_WHICH" -eq 5 ]]; then - load_avg=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 3 | sed -n 2p) - else - load_avg=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 3 | sed -n 3p) - fi + case "$POWERLEVEL9K_LOAD_WHICH" in + 1) + load_select=1 + ;; + 5) + load_select=2 + ;; + 15) + load_select=3 + ;; + esac - if [[ "$OS" == "OSX" ]]; then - cores=$(sysctl -n hw.logicalcpu) - else - cores=$(sysctl -n hw.ncpu) - fi - else - load_avg=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1) - cores=$(nproc) - fi + case "$OS" in + OSX|BSD) + load_avg=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | sed -n ${load_select}p) + if [[ "$OS" == "OSX" ]]; then + cores=$(sysctl -n hw.logicalcpu) + else + cores=$(sysctl -n hw.ncpu) + fi + ;; + *) + load_avg=$(cut -d" " -f${load_select} /proc/loadavg) + cores=$(nproc) + esac # Replace comma load_avg=${load_avg//,/.} if [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.7") ]]; then current_state="critical" -elif [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.5") ]]; then + elif [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.5") ]]; then current_state="warning" else current_state="normal" From 48b4bd1aa4b39bb43dc6e853dd5f4b42cd21700b Mon Sep 17 00:00:00 2001 From: Yann David Date: Thu, 31 Aug 2017 14:15:11 -0400 Subject: [PATCH 4/5] Fix prompt_kubecontext:local:1: not valid in this context: Version: --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 5aa280c6..322de3b7 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1408,7 +1408,7 @@ prompt_dir_writable() { # Kubernetes Current Context prompt_kubecontext() { - local kubectl_version=$(kubectl version --client 2>/dev/null) + local kubectl_version="$(kubectl version --client 2>/dev/null)" if [[ -n "$kubectl_version" ]]; then # Get the current Kubernetes config context's namespaece From 692335975cfc10bc35fe04b758395120c04112cd Mon Sep 17 00:00:00 2001 From: trashbat Date: Tue, 5 Sep 2017 15:46:12 +0100 Subject: [PATCH 5/5] Changed "less than" to "fewer than". --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 5aa280c6..93aca4db 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1533,7 +1533,7 @@ prompt_powerlevel9k_setup() { local term_colors term_colors=$(echotc Co 2>/dev/null) if (( ! $? && ${term_colors:-0} < 256 )); then - print -P "%F{red}WARNING!%f Your terminal appears to support less than 256 colors!" + print -P "%F{red}WARNING!%f Your terminal appears to support fewer than 256 colors!" print -P "If your terminal supports 256 colors, please export the appropriate environment variable" print -P "_before_ loading this theme in your \~\/.zshrc. In most terminal emulators, putting" print -P "%F{blue}export TERM=\"xterm-256color\"%f at the top of your \~\/.zshrc is sufficient."