From 59e64c90512f4c67340e4baf37f0a22d41f765cc Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Fri, 21 Apr 2017 00:06:28 +0400 Subject: [PATCH 01/99] host and user segments --- CHANGELOG.md | 5 ++++ README.md | 48 +++++++++++++++++++++++++++++++++++ powerlevel9k.zsh-theme | 57 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 109 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cacc88e6..b84e5ac7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,11 @@ A new script `debug/font-issues.zsh` was added, so that problems with your font The `ram` segment now shows the available ram instead of free. +### Add new segments `host` and `user` + +The user and host segments allow you to have different icons and colors for both the user and host segments +depending on their state. + ## v0.6.0 - Fixed a bug where the tag display was broken on detached HEADs. diff --git a/README.md b/README.md index 342792f8..2ab722bb 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ The segments that are currently available are: * `dir_writable` - Displays a lock icon, if you do not have write permissions on the current folder. * [`disk_usage`](#disk_usage) - Disk usage of your current partition. * `history` - The command number for the current line. +* [`host`](#host) - Your current host name * [`ip`](#ip) - Shows the current IP address. * [`public_ip`](#public_ip) - Shows your public IP address. * `load` - Your machine's load averages. @@ -101,6 +102,7 @@ The segments that are currently available are: * [`status`](#status) - The return code of the previous command. * `swap` - Prints the current swap size. * [`time`](#time) - System time. +* [`user`](#user) - Your current username * [`vi_mode`](#vi_mode)- Your prompt's Vi editing mode (NORMAL|INSERT). * `ssh` - Indicates whether or not you are in an SSH session. @@ -354,6 +356,35 @@ The `disk_usage` segment will show the usage level of the partition that your cu |POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.| |POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.| +##### host + +The `host` segment (host string) will print the hostname. You can customize the `host` segment. +For example, you can make it to print the full hostname by setting +``` +POWERLEVEL9K_HOST_TEMPLATE="`hostname -f`" +``` + +You can also modify the COLOURS for the two states - LOCAL and REMOTE, by setting +``` +POWERLEVEL9K_HOST_LOCAL_BACKGROUND="green" +POWERLEVEL9K_HOST_LOCAL_FOREGROUND="white" +POWERLEVEL9K_HOST_REMOTE_BACKGROUND="red" +POWERLEVEL9K_HOST_REMOTE_FOREGROUND="yellow" +``` + +Currently, LOCAL hosts will show the host icon and remote hosts will show the SSH icon. You can override them by setting +``` +POWERLEVEL9K_HOST_ICON="\uF109 " #  +POWERLEVEL9K_SSH_ICON="\uF489 " #  +``` + +You can set the `POWERLEVEL9K_HOST_TEMPLATE` variable to change how the hostname is displayed. +See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information] +for details. The default is set to %m which will show the hostname up to the first ‘.’ +You can set it to %{N}m where N is an integer to show that many segments of system +hostname. Setting N to a negative integer will show that many segments from the +end of the hostname. + ##### ip This segment tries to examine all currently used network interfaces and prints @@ -436,6 +467,23 @@ segment, as well: # Output time, date, and a symbol from the "Awesome Powerline Font" set POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S \uE868 %d.%m.%y}" ``` +##### user + +The `user` segment (user string) will print the username. You can customize the `user` segment. +For example, you can modify the COLOURS for the two states - DEFAULT and ROOT, by setting +``` +POWERLEVEL9K_USER_DEFAULT_BACKGROUND="green" +POWERLEVEL9K_USER_DEFAULT_FOREGROUND="white" +POWERLEVEL9K_USER_ROOT_BACKGROUND="red" +POWERLEVEL9K_USER_ROOT_FOREGROUND="yellow" +``` + +You can also override the icons by setting +``` +POWERLEVEL9K_USER_ICON="\uF415" #  +POWERLEVEL9K_ROOT_ICON="#" +``` + ##### vcs By default, the `vcs` segment will provide quite a bit of information. Further diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bbd1ec44..c791a845 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -567,6 +567,61 @@ prompt_context() { "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" } +################################################################ +# User: user (who am I) +# Note that if $DEFAULT_USER is not set, this prompt segment will always print +set_default POWERLEVEL9K_USER_TEMPLATE "%n" +prompt_user() { + local current_state="DEFAULT" + typeset -AH user_state + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + if [[ $(print -P "%#") == '#' ]]; then + user_state=( + "STATE" "ROOT" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "ROOT_ICON" + ) + elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then + user_state=( + "STATE" "DEFAULT" + "CONTENT" "$USER" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "011" + "VISUAL_IDENTIFIER" "USER_ICON" + ) + fi + fi + "$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" +} + +################################################################ +# Host: machine (where am I) +set_default POWERLEVEL9K_HOST_TEMPLATE "%m" +prompt_host() { + local current_state="LOCAL" + typeset -AH host_state + if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then + host_state=( + "STATE" "REMOTE" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SSH_ICON" + ) + else + host_state=( + "STATE" "LOCAL" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "011" + "VISUAL_IDENTIFIER" "HOST_ICON" + ) + fi + "$1_prompt_segment" "$0_${host_state[STATE]}" "$2" "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" +} + # The 'custom` prompt provides a way for users to invoke commands and display # the output in a segment. prompt_custom() { @@ -664,7 +719,7 @@ prompt_dir() { break; fi done - + local packageName=$(jq '.name' ${pkgFile} 2> /dev/null \ || node -e 'console.log(require(process.argv[1]).name);' ${pkgFile} 2>/dev/null \ || cat "${pkgFile}" 2> /dev/null | grep -m 1 "\"name\"" | awk -F ':' '{print $2}' | awk -F '"' '{print $2}' 2>/dev/null \ From 94ff40d2d1823f805f58759b1420e6fe15e28001 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 27 Apr 2017 22:16:20 +0400 Subject: [PATCH 02/99] Removed POWERLEVEL9K_ALWAYS_SHOW_CONTEXT --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c791a845..0ae046d5 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -574,7 +574,7 @@ set_default POWERLEVEL9K_USER_TEMPLATE "%n" prompt_user() { local current_state="DEFAULT" typeset -AH user_state - if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then if [[ $(print -P "%#") == '#' ]]; then user_state=( "STATE" "ROOT" @@ -583,7 +583,7 @@ prompt_user() { "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "ROOT_ICON" ) - elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then + else user_state=( "STATE" "DEFAULT" "CONTENT" "$USER" From 61790bf24213f1fb8b98d853e47a37a1a75d3a10 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 27 Apr 2017 22:19:17 +0400 Subject: [PATCH 03/99] Revised User segment in README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 2ab722bb..f62511b1 100644 --- a/README.md +++ b/README.md @@ -484,6 +484,12 @@ POWERLEVEL9K_USER_ICON="\uF415" #  POWERLEVEL9K_ROOT_ICON="#" ``` +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`DEFAULT_USER`|None|Username to consider a "default context" (you can also set `$USER`).| +|`POWERLEVEL9K_ALWAYS_SHOW_USER`|false|Always show the username, but conditionalize the hostname.| +|`POWERLEVEL9K_USER_TEMPLATE`|%n|Default username prompt (username). Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions| + ##### vcs By default, the `vcs` segment will provide quite a bit of information. Further From 98a00d31a802887250b359793c371e64cf951e67 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Mon, 1 May 2017 21:28:22 -0400 Subject: [PATCH 04/99] Merge branch 'battery' of https://github.com/onaforeignshore/powerlevel9k into onaforeignshore-battery --- README.md | 52 +++++++++++++++++++++++++++++++++++++++--- powerlevel9k.zsh-theme | 21 ++++++++++++++--- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ad2a3e9f..2faeeb8e 100644 --- a/README.md +++ b/README.md @@ -184,9 +184,8 @@ your `~/.zshrc`: ##### battery -This segment will display your current battery status (fails gracefully on -systems without a battery). It is supported on both OSX and Linux (note that it -requires `acpi` on Linux). +The default settings for this segment will display your current battery status (fails gracefully on +systems without a battery). It is supported on both OSX and Linux (note that it requires `acpi` on Linux). | Variable | Default Value | Description | |----------|---------------|-------------| @@ -201,6 +200,53 @@ Note that you can [modify the `_FOREGROUND` color](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization) without affecting the icon color. +The battery segment can also be extended to change the icon automatically depending on the battery level. +This will override the default battery icon. In order to do this, you need to define the +`POWERLEVEL9k_BATTERY_STAGES` variable. + +| Variable | Default Value | Description | +| `POWERLEVEL9K_BATTERY_STAGES`|Unset|A string or array to indicate the stages.| + +If you want to use a string, you can declare the variable as follows: +```zsh +POWERLEVEL9K_BATTERY_STAGES="▁▂▃▄▅▆▇█" +``` + +If you require extra spacing after the icon, you will have to set it as an array, +since spaces in the string will be used as one of the stages and you will get a +missing icon. To do this, declare the variable as follows: +```zsh +POWERLEVEL9K_BATTERY_STAGES=($'\u2581 ' $'\u2582 ' $'\u2583 ' $'\u2584 ' $'\u2585 ' $'\u2586 ' $'\u2587 ' $'\u2588 ') +``` + +You can also use a multiple character "icon" if you want a longer battery icon. To do +this, declare the variable as follows: +```zsh +POWERLEVEL9K_BATTERY_STAGES=( + $'▏ ▏' $'▎ ▏' $'▍ ▏' $'▌ ▏' $'▋ ▏' $'▊ ▏' $'▉ ▏' $'█ ▏' + $'█▏ ▏' $'█▎ ▏' $'█▍ ▏' $'█▌ ▏' $'█▋ ▏' $'█▊ ▏' $'█▉ ▏' $'██ ▏' + $'██ ▏' $'██▎ ▏' $'██▍ ▏' $'██▌ ▏' $'██▋ ▏' $'██▊ ▏' $'██▉ ▏' $'███ ▏' + $'███ ▏' $'███▎ ▏' $'███▍ ▏' $'███▌ ▏' $'███▋ ▏' $'███▊ ▏' $'███▉ ▏' $'████ ▏' + $'████ ▏' $'████▎▏' $'████▍▏' $'████▌▏' $'████▋▏' $'████▊▏' $'████▉▏' $'█████▏' ) +``` + +It is now also possible to change the background of the segment automatically depending on +the battery level. This will override the following variables: `POWERLEVEL9K_BATTERY_CHARGING`, +`POWERLEVEL9K_BATTERY_CHARGED`, `POWERLEVEL9K_BATTERY_DISCONNECTED`, and `POWERLEVEL9K_BATTERY_LOW_COLOR`. +In order to do this, we define a color array (from low to high) as follows: +```zsh +POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND=(196 202 208 214 220 226 190 154 118 82 46) +``` + +|Brightness|Possible Array| +|Bright Colors|(196 202 208 214 220 226 190 154 118 82 46)| +|Normal Colors|(124 130 136 142 148 112 76 40 34 28 22)| +|Subdued Colors|( 88 94 100 106 70 34 28 22)| + +Please note the following: +* an array declarations start with `(` and end with `)`. +* both the icon and background changing levels are automatically calculated, so they can be any length. + ##### command_execution_time Display the time the previous command took to execute if the time is above diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 3eba616c..e7665225 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -468,9 +468,24 @@ prompt_battery() { message="$bat_percent%%" fi - # Draw the prompt_segment - if [[ -n $bat_percent ]]; then - "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${battery_states[$current_state]}" "$message" 'BATTERY_ICON' + # override default icon if we are using battery stages + if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_STAGES} - 1 ) )) + if [[ $segment > 1 ]]; then + local offset=$(( ($bat_percent / $segment) + 1 )) + # check if the stages are in an array or a string + [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} + fi + fi + + # override the default color if we are using a color level array + if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) + local offset=$(( ($bat_percent / $segment) + 1 )) + "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + else + # Draw the prompt_segment + "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" fi } From cae2a7927ddd3307e6639603cc4e82e6760e9bbd Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Mon, 1 May 2017 21:37:12 -0400 Subject: [PATCH 05/99] Updates to README and CHANGELOG for changes from #498. --- CHANGELOG.md | 5 +++++ README.md | 33 ++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6257416b..e37e5c0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v0.6.4 + +- Significant enhancements to the `battery` segment. Check out the README to + read more! + ## v0.6.3 - Fixed susceptibility to [pw3nage exploit](https://github.com/njhartwell/pw3nage). diff --git a/README.md b/README.md index 2faeeb8e..0de4fab5 100644 --- a/README.md +++ b/README.md @@ -200,14 +200,16 @@ Note that you can [modify the `_FOREGROUND` color](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization) without affecting the icon color. -The battery segment can also be extended to change the icon automatically depending on the battery level. -This will override the default battery icon. In order to do this, you need to define the -`POWERLEVEL9k_BATTERY_STAGES` variable. +You can also change the battery icon automatically depending on the battery +level. This will override the default battery icon. In order to do this, you +need to define the `POWERLEVEL9k_BATTERY_STAGES` variable. | Variable | Default Value | Description | -| `POWERLEVEL9K_BATTERY_STAGES`|Unset|A string or array to indicate the stages.| +| `POWERLEVEL9K_BATTERY_STAGES`|Unset|A string or array, which each index indicates a charge level.| -If you want to use a string, you can declare the variable as follows: +Powerlevel9k will use each index of the string or array as a stage to indicate battery +charge level, progressing from left to right. You can provide any number of +stages. The setting below, for example, provides 8 stages for Powerlevel9k to use. ```zsh POWERLEVEL9K_BATTERY_STAGES="▁▂▃▄▅▆▇█" ``` @@ -219,8 +221,8 @@ missing icon. To do this, declare the variable as follows: POWERLEVEL9K_BATTERY_STAGES=($'\u2581 ' $'\u2582 ' $'\u2583 ' $'\u2584 ' $'\u2585 ' $'\u2586 ' $'\u2587 ' $'\u2588 ') ``` -You can also use a multiple character "icon" if you want a longer battery icon. To do -this, declare the variable as follows: +Using the array syntax, you can create stages comprised of multiple characters. +The below setting provides 40 battery stages. ```zsh POWERLEVEL9K_BATTERY_STAGES=( $'▏ ▏' $'▎ ▏' $'▍ ▏' $'▌ ▏' $'▋ ▏' $'▊ ▏' $'▉ ▏' $'█ ▏' @@ -230,23 +232,24 @@ POWERLEVEL9K_BATTERY_STAGES=( $'████ ▏' $'████▎▏' $'████▍▏' $'████▌▏' $'████▋▏' $'████▊▏' $'████▉▏' $'█████▏' ) ``` -It is now also possible to change the background of the segment automatically depending on -the battery level. This will override the following variables: `POWERLEVEL9K_BATTERY_CHARGING`, -`POWERLEVEL9K_BATTERY_CHARGED`, `POWERLEVEL9K_BATTERY_DISCONNECTED`, and `POWERLEVEL9K_BATTERY_LOW_COLOR`. -In order to do this, we define a color array (from low to high) as follows: +You can also change the background of the segment automatically depending on the +battery level. This will override the following variables: +`POWERLEVEL9K_BATTERY_CHARGING`, `POWERLEVEL9K_BATTERY_CHARGED`, +`POWERLEVEL9K_BATTERY_DISCONNECTED`, and `POWERLEVEL9K_BATTERY_LOW_COLOR`. In +order to do this, define a color array, from low to high, as shown below: ```zsh POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND=(196 202 208 214 220 226 190 154 118 82 46) ``` +As with the battery stages, you can use any number of colors and Powerlevel9k +will automatically use all of them appropriately. + +Some example settings: |Brightness|Possible Array| |Bright Colors|(196 202 208 214 220 226 190 154 118 82 46)| |Normal Colors|(124 130 136 142 148 112 76 40 34 28 22)| |Subdued Colors|( 88 94 100 106 70 34 28 22)| -Please note the following: -* an array declarations start with `(` and end with `)`. -* both the icon and background changing levels are automatically calculated, so they can be any length. - ##### command_execution_time Display the time the previous command took to execute if the time is above From e6c37b6bc5ba26928ce75720d7fa1c2addb5ccac Mon Sep 17 00:00:00 2001 From: guixxx Date: Sun, 7 May 2017 10:34:54 -0300 Subject: [PATCH 06/99] Icons for Windows/Cygwin + Refixes 32-bit support --- functions/icons.zsh | 4 ++++ functions/utilities.zsh | 4 ++++ powerlevel9k.zsh-theme | 10 +++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index c2cdcba5..7b3bba78 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -42,6 +42,7 @@ case $POWERLEVEL9K_MODE in MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' APPLE_ICON $'\uE26E' #  + WINDOWS_ICON $'\uE26F' #  FREEBSD_ICON $'\U1F608 ' # 😈 ANDROID_ICON $'\uE270' #  LINUX_ICON $'\uE271' #  @@ -112,6 +113,7 @@ case $POWERLEVEL9K_MODE in MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uF179' #  + WINDOWS_ICON $'\uF17A' #  FREEBSD_ICON $'\U1F608 ' # 😈 ANDROID_ICON $'\uE17B' #  LINUX_ICON $'\uF17C' #  @@ -178,6 +180,7 @@ case $POWERLEVEL9K_MODE in MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uF179' #  + WINDOWS_ICON $'\uF17A' #  FREEBSD_ICON $'\UF30E ' #  ANDROID_ICON $'\uF17B' #  LINUX_ICON $'\uF17C' #  @@ -244,6 +247,7 @@ case $POWERLEVEL9K_MODE in MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\u2500' MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\u2500 ' APPLE_ICON 'OSX' + WINDOWS_ICON 'WIN' FREEBSD_ICON 'BSD' ANDROID_ICON 'And' LINUX_ICON 'Lx' diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 86e5ba0e..9bd82060 100644 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -85,6 +85,10 @@ case $(uname) in OS='OSX' OS_ICON=$(print_icon 'APPLE_ICON') ;; + CYGWIN_NT-*) + OS='Windows' + OS_ICON=$(print_icon 'WINDOWS_ICON') + ;; FreeBSD) OS='BSD' OS_ICON=$(print_icon 'FREEBSD_ICON') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 19da5bc9..757db12e 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1295,7 +1295,7 @@ powerlevel9k_prepare_prompts() { _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) # Reset start time - _P9K_TIMER_START=0xFFFFFFFF + _P9K_TIMER_START=0x7FFFFFFF if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) @@ -1328,12 +1328,12 @@ NEWLINE=' } prompt_powerlevel9k_setup() { - # I decided to use the value below for better supporting 32-bit CPUs, since the previous value "99999999999" was causing issues on my Android phone, which is powered by an armv7l - # We don't have to change that until 19 January of 2038! :) + # The value below was set to better support 32-bit CPUs. + # It's the maximum _signed_ integer value on 32-bit CPUs. + # Please don't change it until 19 January of 2038. ;) # Disable false display of command execution time - # Maximum integer on 32-bit CPUs - _P9K_TIMER_START=2147483647 + _P9K_TIMER_START=0x7FFFFFFF # The prompt function will set these prompt_* options after the setup function # returns. We need prompt_subst so we can safely run commands in the prompt From 543bd2f844c561dea4e7900dd934a007b737331f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Wed, 3 May 2017 23:53:59 -0400 Subject: [PATCH 07/99] status: add option for support pipes Added new option (POWERLEVEL9K_STATUS_SHOW_PIPESTATUS) that shows the status for all piped commands, not just the right-most. Closes #514 --- README.md | 1 + powerlevel9k.zsh-theme | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index caeeccbb..6d3a1fc2 100644 --- a/README.md +++ b/README.md @@ -463,6 +463,7 @@ This segment shows the return code of the last command. |----------|---------------|-------------| |`POWERLEVEL9K_STATUS_VERBOSE`|`true`|Set to false if you wish to not show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE` to false.| |`POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE`|`false`|Set to true if you wish to show this segment when the last command completed successfully in non-verbose mode.| +|`POWERLEVEL9K_STATUS_SHOW_PIPESTATUS`|`false`|Set to true if you wish to show the exit status for all piped commands.| ##### ram diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 2d664911..eb3cc8ab 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1019,10 +1019,30 @@ prompt_ssh() { # Status: return code if verbose, otherwise just an icon if an error occurred set_default POWERLEVEL9K_STATUS_VERBOSE true set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false +set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS false prompt_status() { - if [[ "$RETVAL" -ne 0 ]]; then + local ec_text + local ec_sum + local ec + + if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then + ec_text=${RETVALS[1]} + ec_sum=${RETVALS[1]} + + for ec in "${(@)RETVALS[2,-1]}"; do + ec_text="${ec_text}|${ec}" + ec_sum=$(( $ec_sum + $ec )) + done + else + # We use RETVAL instead of the right-most RETVALS item because + # PIPE_FAIL may be set. + ec_text=${RETVAL} + ec_sum=${RETVAL} + fi + + if (( ec_sum > 0 )); then if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then - "$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$RETVAL" 'CARRIAGE_RETURN_ICON' + "$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$ec_text" 'CARRIAGE_RETURN_ICON' else "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' fi @@ -1306,6 +1326,7 @@ powerlevel9k_preexec() { set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false powerlevel9k_prepare_prompts() { RETVAL=$? + RETVALS=( "$pipestatus[@]" ) _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) From 25a6c3a4a8f2c8882d89c5634400bb57a82f3a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Fri, 12 May 2017 22:13:37 -0400 Subject: [PATCH 08/99] pipestatus: default to true (on) --- README.md | 2 +- powerlevel9k.zsh-theme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d3a1fc2..cec4c746 100644 --- a/README.md +++ b/README.md @@ -463,7 +463,7 @@ This segment shows the return code of the last command. |----------|---------------|-------------| |`POWERLEVEL9K_STATUS_VERBOSE`|`true`|Set to false if you wish to not show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE` to false.| |`POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE`|`false`|Set to true if you wish to show this segment when the last command completed successfully in non-verbose mode.| -|`POWERLEVEL9K_STATUS_SHOW_PIPESTATUS`|`false`|Set to true if you wish to show the exit status for all piped commands.| +|`POWERLEVEL9K_STATUS_SHOW_PIPESTATUS`|`true`|Set to true if you wish to show the exit status for all piped commands.| ##### ram diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index eb3cc8ab..0f2445e6 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1019,7 +1019,7 @@ prompt_ssh() { # Status: return code if verbose, otherwise just an icon if an error occurred set_default POWERLEVEL9K_STATUS_VERBOSE true set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false -set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS false +set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true prompt_status() { local ec_text local ec_sum From 1619c74ad8aff47383989efadc1e4553a83cf4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Thu, 4 May 2017 02:32:18 -0400 Subject: [PATCH 09/99] newline: add new segment --- README.md | 8 ++++++++ powerlevel9k.zsh-theme | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/README.md b/README.md index caeeccbb..b52edeb7 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ The segments that are currently available are: * [`command_execution_time`](#command_execution_time) - Display the time the current command took to execute. * [`todo`](http://todotxt.com/) - Shows the number of tasks in your todo.txt tasks file. * `detect_virt` - Virtualization detection with systemd +* `newline` - Continues the prompt on a new line. --------------------------------------------------------------------------------- @@ -442,6 +443,13 @@ segment will not be displayed. |`POWERLEVEL9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.| |`POWERLEVEL9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained| +##### newline + +Puts a newline in your prompt so you can continue using segments on the next line. + +This allows you to use segments on both lines, unlike `POWERLEVEL9K_PROMPT_ON_NEWLINE` and +`POWERLEVEL9K_RPROMPT_ON_NEWLINE`. + ##### rbenv This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack. diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 2d664911..83c5966e 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -337,6 +337,21 @@ prompt_background_jobs() { fi } +# A newline in your prompt, so you can segments on multiple lines. +prompt_newline() { + local lws rws + lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS + rws=$POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= + POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS= + "$1_prompt_segment" \ + "$0" \ + "$2" \ + "NONE" "NONE" $'\n' + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws + POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=$rws +} + # Segment that indicates usage level of current partition. set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 From 161c995625fc655eb3228a88f5ce1ad79fd1ede0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Thu, 4 May 2017 02:44:37 -0400 Subject: [PATCH 10/99] newline: can't work with right side --- README.md | 5 +++-- powerlevel9k.zsh-theme | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b52edeb7..bc9b4462 100644 --- a/README.md +++ b/README.md @@ -447,8 +447,9 @@ segment will not be displayed. Puts a newline in your prompt so you can continue using segments on the next line. -This allows you to use segments on both lines, unlike `POWERLEVEL9K_PROMPT_ON_NEWLINE` and -`POWERLEVEL9K_RPROMPT_ON_NEWLINE`. +This allows you to use segments on both lines, unlike `POWERLEVEL9K_PROMPT_ON_NEWLINE`. + +This only works on the left side. On the right side it does nothing. ##### rbenv diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 83c5966e..bcce12f4 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -339,17 +339,15 @@ prompt_background_jobs() { # A newline in your prompt, so you can segments on multiple lines. prompt_newline() { - local lws rws + local lws + [[ "$1" == "right" ]] && return lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS - rws=$POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= - POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS= "$1_prompt_segment" \ "$0" \ "$2" \ "NONE" "NONE" $'\n' POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws - POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=$rws } # Segment that indicates usage level of current partition. From e9e3e9dc538edc82bf8071919eca2fc9c56292a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Fri, 12 May 2017 21:07:50 -0400 Subject: [PATCH 11/99] newline: support PROMPT_ON_NEWLINE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The newline segment will now show ├─ when using `POWERLEVEL9K_PROMPT_ON_NEWLINE` Note: This can be overridden via `POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX` --- functions/icons.zsh | 12 ++++++++---- powerlevel9k.zsh-theme | 8 ++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 7b3bba78..72e0fbe4 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -39,8 +39,9 @@ case $POWERLEVEL9K_MODE in FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' + MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ + MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uE26E' #  WINDOWS_ICON $'\uE26F' #  FREEBSD_ICON $'\U1F608 ' # 😈 @@ -111,6 +112,7 @@ case $POWERLEVEL9K_MODE in SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uF179' #  WINDOWS_ICON $'\uF17A' #  @@ -178,6 +180,7 @@ case $POWERLEVEL9K_MODE in SYMFONY_ICON $'\uE757' #  NODE_ICON $'\uE617 ' #  MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uF179' #  WINDOWS_ICON $'\uF17A' #  @@ -244,8 +247,9 @@ case $POWERLEVEL9K_MODE in FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\u2500' - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\u2500 ' + MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ + MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON 'OSX' WINDOWS_ICON 'WIN' FREEBSD_ICON 'BSD' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bcce12f4..cad455e6 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -339,14 +339,18 @@ prompt_background_jobs() { # A newline in your prompt, so you can segments on multiple lines. prompt_newline() { - local lws + local lws newline [[ "$1" == "right" ]] && return + newline=$'\n' lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then + newline="${newline}$(print_icon 'MULTILINE_NEWLINE_PROMPT_PREFIX')" + fi POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= "$1_prompt_segment" \ "$0" \ "$2" \ - "NONE" "NONE" $'\n' + "NONE" "NONE" "${newline}" POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws } From 38d5f4d056027984290f97ea60ede9cc74494f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Thu, 4 May 2017 01:27:56 -0400 Subject: [PATCH 12/99] nvm: improve default detection This is also (marginally) faster than before. --- powerlevel9k.zsh-theme | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 2d664911..d99b6e38 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -889,13 +889,16 @@ prompt_node_version() { # Node version from NVM # Only prints the segment if different than the default value prompt_nvm() { - [[ ! $(type nvm) =~ 'nvm is a shell function'* ]] && return - local node_version=$(nvm current) - [[ -z "${node_version}" ]] || [[ ${node_version} = "none" ]] && return - local nvm_default=$(cat $NVM_DIR/alias/default) + local node_version nvm_default + (( $+functions[nvm_version] )) || return + + node_version=$(nvm_version current) + [[ -z "${node_version}" || ${node_version} == "none" ]] && return + + nvm_default=$(nvm_version default) [[ "$node_version" =~ "$nvm_default" ]] && return - $1_prompt_segment "$0" "$2" "green" "011" "${node_version:1}" 'NODE_ICON' + $1_prompt_segment "$0" "$2" "magenta" "black" "${node_version:1}" 'NODE_ICON' } # NodeEnv Prompt From feb942d4536004ecc862d6c6447599359b64c96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Thu, 4 May 2017 02:20:29 -0400 Subject: [PATCH 13/99] add function to disable powerlevel9k Sometimes you have to disable your prompt. :-( --- powerlevel9k.zsh-theme | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 2d664911..ab7ec346 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1412,4 +1412,9 @@ prompt_powerlevel9k_setup() { add-zsh-hook preexec powerlevel9k_preexec } +prompt_powerlevel9k_teardown() { + add-zsh-hook -D precmd powerlevel9k_\* + add-zsh-hook -D preexec powerlevel9k_\* +} + prompt_powerlevel9k_setup "$@" From 382c8215390373430ae07eea0858e2b3dc97689c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Fri, 12 May 2017 21:30:42 -0400 Subject: [PATCH 14/99] teardown: reset PROMPT and RPROMPT --- powerlevel9k.zsh-theme | 2 ++ 1 file changed, 2 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index ab7ec346..28c606d6 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1415,6 +1415,8 @@ prompt_powerlevel9k_setup() { prompt_powerlevel9k_teardown() { add-zsh-hook -D precmd powerlevel9k_\* add-zsh-hook -D preexec powerlevel9k_\* + PROMPT='%m%# ' + RPROPT= } prompt_powerlevel9k_setup "$@" From e0a6246ecc81e94e1f402cac1ddd67d34c1ac5a1 Mon Sep 17 00:00:00 2001 From: Christian Rebischke Date: Sun, 21 May 2017 15:04:24 +0200 Subject: [PATCH 15/99] swapped colors for virtualization detection, black on yellow was pain for the eyes --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 2d664911..4f30a831 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -790,12 +790,12 @@ prompt_detect_virt() { if [[ "$virt" == "none" ]]; then if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then virt="chroot" - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$virt" + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" else ; fi else - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$virt" + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" fi } From e844fc4c72e20f84d8022ff9591e75d4a30886cf Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Mon, 22 May 2017 21:12:59 -0400 Subject: [PATCH 16/99] Incorporating @dritter's feedback from #524. --- README.md | 7 ++++--- functions/icons.zsh | 8 ++++---- powerlevel9k.zsh-theme | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a4608c41..1e52bfb4 100644 --- a/README.md +++ b/README.md @@ -445,9 +445,10 @@ segment will not be displayed. ##### newline -Puts a newline in your prompt so you can continue using segments on the next line. - -This allows you to use segments on both lines, unlike `POWERLEVEL9K_PROMPT_ON_NEWLINE`. +Puts a newline in your prompt so you can continue using segments on the next +line. This allows you to use segments on both lines, unlike +`POWERLEVEL9K_PROMPT_ON_NEWLINE`, which simply separates segments from the +prompt itself. This only works on the left side. On the right side it does nothing. diff --git a/functions/icons.zsh b/functions/icons.zsh index 72e0fbe4..238b6b9e 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -41,7 +41,7 @@ case $POWERLEVEL9K_MODE in NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ + MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uE26E' #  WINDOWS_ICON $'\uE26F' #  FREEBSD_ICON $'\U1F608 ' # 😈 @@ -113,7 +113,7 @@ case $POWERLEVEL9K_MODE in NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ + MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uF179' #  WINDOWS_ICON $'\uF17A' #  FREEBSD_ICON $'\U1F608 ' # 😈 @@ -181,7 +181,7 @@ case $POWERLEVEL9K_MODE in NODE_ICON $'\uE617 ' #  MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ + MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uF179' #  WINDOWS_ICON $'\uF17A' #  FREEBSD_ICON $'\UF30E ' #  @@ -249,7 +249,7 @@ case $POWERLEVEL9K_MODE in NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ + MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON 'OSX' WINDOWS_ICON 'WIN' FREEBSD_ICON 'BSD' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index e4629646..ec10be85 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1352,7 +1352,7 @@ powerlevel9k_prepare_prompts() { if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) -$(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')' +$(print_icon 'MULTILINE_LAST_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 # prompt. To do so, there is just a quite ugly workaround: Before zsh draws From a7409272ac215a4cdb9b8ac17fe78b521306c383 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Mon, 22 May 2017 21:20:56 -0400 Subject: [PATCH 17/99] Fixing typo in #525 to teardown `RPROMPT` --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 2138f54b..291439ef 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1454,7 +1454,7 @@ prompt_powerlevel9k_teardown() { add-zsh-hook -D precmd powerlevel9k_\* add-zsh-hook -D preexec powerlevel9k_\* PROMPT='%m%# ' - RPROPT= + RPROMPT= } prompt_powerlevel9k_setup "$@" From 325e01b9f265e78c8c88ad88bc6342aa07302dcc Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Mon, 22 May 2017 21:23:52 -0400 Subject: [PATCH 18/99] Updating the README to add a note about `teardown` feature. --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 1e52bfb4..ef9c8c88 100644 --- a/README.md +++ b/README.md @@ -558,6 +558,21 @@ is count your source files and test files, and calculate the ratio between them. Just enough to give you a quick overview about the test situation of the project you are dealing with. +### Disabling / Enabling Powerlevel9k + +You can disable P9k and return to a very basic prompt at any time simply by +calling: + +```zsh +$ prompt_powerlevel9k_teardown +``` + +You can then re-enable it by calling: + +```zsh +$ prompt_powerlevel9k_setup +``` + ### tl; dr Want to just get a quick start? Check out the [Show Off Your From cf806f097b42c798223d6dc68ff551b4fc90ea43 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Tue, 23 May 2017 19:14:52 +0400 Subject: [PATCH 19/99] updated render check logic --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0ae046d5..d7ae04ff 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -574,7 +574,7 @@ set_default POWERLEVEL9K_USER_TEMPLATE "%n" prompt_user() { local current_state="DEFAULT" typeset -AH user_state - if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]]; then if [[ $(print -P "%#") == '#' ]]; then user_state=( "STATE" "ROOT" @@ -592,8 +592,8 @@ prompt_user() { "VISUAL_IDENTIFIER" "USER_ICON" ) fi + "$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" fi - "$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" } ################################################################ From de6a9388e9f4467e1e68bff7e24051a7d5c2b4b0 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Tue, 23 May 2017 19:16:46 +0400 Subject: [PATCH 20/99] updated to fix copy/paste --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f62511b1..db58c039 100644 --- a/README.md +++ b/README.md @@ -486,8 +486,8 @@ POWERLEVEL9K_ROOT_ICON="#" | Variable | Default Value | Description | |----------|---------------|-------------| -|`DEFAULT_USER`|None|Username to consider a "default context" (you can also set `$USER`).| -|`POWERLEVEL9K_ALWAYS_SHOW_USER`|false|Always show the username, but conditionalize the hostname.| +|`DEFAULT_USER`|None|Username to consider a "default context" (you can also set it to `$USER`).| +|`POWERLEVEL9K_ALWAYS_SHOW_USER`|false|Always show the username.| |`POWERLEVEL9K_USER_TEMPLATE`|%n|Default username prompt (username). Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions| ##### vcs From 19fc709a168957219095c81a49261a21fbf9beab Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Thu, 25 May 2017 16:00:44 -0400 Subject: [PATCH 21/99] Moving some parts of README to the Wiki. --- README.md | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index b4450ca7..890875ad 100644 --- a/README.md +++ b/README.md @@ -313,11 +313,11 @@ elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`. You can customize the `context` segment. For example, you can make it to print the full hostname by setting + ``` POWERLEVEL9K_CONTEXT_TEMPLATE="%n@`hostname -f`" ``` - You can set the `POWERLEVEL9K_CONTEXT_HOST_DEPTH` variable to change how the hostname is displayed. See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information] for details. The default is set to %m which will show the hostname up to the first ‘.’ @@ -414,32 +414,25 @@ The `disk_usage` segment will show the usage level of the partition that your cu ##### host -The `host` segment (host string) will print the hostname. You can customize the `host` segment. -For example, you can make it to print the full hostname by setting -``` -POWERLEVEL9K_HOST_TEMPLATE="`hostname -f`" -``` +The `host` segment will print the hostname. + +You can set the `POWERLEVEL9K_HOST_TEMPLATE` variable to change how the hostname +is displayed. See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information] +for details. The default is set to `%m` which will show the hostname up to the +first `.`. You can set it to `%{N}m` where N is an integer to show that many +segments of system hostname. Setting `N` to a negative integer will show that many +segments from the end of the hostname. -You can also modify the COLOURS for the two states - LOCAL and REMOTE, by setting ``` -POWERLEVEL9K_HOST_LOCAL_BACKGROUND="green" -POWERLEVEL9K_HOST_LOCAL_FOREGROUND="white" -POWERLEVEL9K_HOST_REMOTE_BACKGROUND="red" -POWERLEVEL9K_HOST_REMOTE_FOREGROUND="yellow" +POWERLEVEL9K_HOST_TEMPLATE="%2m" ``` -Currently, LOCAL hosts will show the host icon and remote hosts will show the SSH icon. You can override them by setting +By default, LOCAL hosts will show the host icon and remote hosts will show the SSH icon. You can override them by setting ``` POWERLEVEL9K_HOST_ICON="\uF109 " #  POWERLEVEL9K_SSH_ICON="\uF489 " #  ``` -You can set the `POWERLEVEL9K_HOST_TEMPLATE` variable to change how the hostname is displayed. -See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information] -for details. The default is set to %m which will show the hostname up to the first ‘.’ -You can set it to %{N}m where N is an integer to show that many segments of system -hostname. Setting N to a negative integer will show that many segments from the -end of the hostname. ##### ip @@ -535,16 +528,10 @@ POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S \uE868 %d.%m.%y}" ``` ##### user -The `user` segment (user string) will print the username. You can customize the `user` segment. -For example, you can modify the COLOURS for the two states - DEFAULT and ROOT, by setting -``` -POWERLEVEL9K_USER_DEFAULT_BACKGROUND="green" -POWERLEVEL9K_USER_DEFAULT_FOREGROUND="white" -POWERLEVEL9K_USER_ROOT_BACKGROUND="red" -POWERLEVEL9K_USER_ROOT_FOREGROUND="yellow" -``` +The `user` segment will print the username. + +You can also override the icons by setting: -You can also override the icons by setting ``` POWERLEVEL9K_USER_ICON="\uF415" #  POWERLEVEL9K_ROOT_ICON="#" @@ -552,9 +539,9 @@ POWERLEVEL9K_ROOT_ICON="#" | Variable | Default Value | Description | |----------|---------------|-------------| -|`DEFAULT_USER`|None|Username to consider a "default context" (you can also set it to `$USER`).| -|`POWERLEVEL9K_ALWAYS_SHOW_USER`|false|Always show the username.| -|`POWERLEVEL9K_USER_TEMPLATE`|%n|Default username prompt (username). Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions| +|`DEFAULT_USER`|None|Username to consider a "default context".| +|`POWERLEVEL9K_ALWAYS_SHOW_USER`|`false`|Always print this segment.| +|`POWERLEVEL9K_USER_TEMPLATE`|`%n`|Default username prompt. Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions| ##### vcs From d8d6c752fdeabf4de96ba96a361069e1fe8e65da Mon Sep 17 00:00:00 2001 From: Jordan Taylor Date: Fri, 26 May 2017 09:02:14 -0400 Subject: [PATCH 22/99] added the current context prompt for your kubectl config --- powerlevel9k.zsh-theme | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 666ce965..fa2e94ab 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1353,6 +1353,20 @@ prompt_dir_writable() { fi } +# Kubernetes Current Context +prompt_kubecontext() { + local kubectl=$(kubectl version 2>/dev/null) + + if [[ -n "kubectl_version" ]]; then + # Get the current Kubernetes config context's namespaece + local k8s_namespace=$(kubectl config get-contexts --no-headers | grep '*' | awk '{print $5}') + # Get the current Kuberenetes context + local k8s_context=$(kubectl config current-context) + "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_context/$k8s_namespace \u2388" + fi +} + + ################################################################ # Prompt processing and drawing ################################################################ From c11c3a55de2be5a9e11b55426d0afbca43aace4d Mon Sep 17 00:00:00 2001 From: Jason Hutchinson Date: Fri, 26 May 2017 13:27:17 -0500 Subject: [PATCH 23/99] use p9k print_icon for kubecontext segment --- functions/icons.zsh | 4 ++++ powerlevel9k.zsh-theme | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 238b6b9e..e38d66a2 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -84,6 +84,7 @@ case $POWERLEVEL9K_MODE in LOCK_ICON $'\UE138' #  EXECUTION_TIME_ICON $'\UE89C' #  SSH_ICON '(ssh)' + KUBERNETES_ICON $'\U2388' # ⎈ ) ;; 'awesome-fontconfig') @@ -152,6 +153,7 @@ case $POWERLEVEL9K_MODE in LOCK_ICON $'\UE138' #  EXECUTION_TIME_ICON $'\uF253' SSH_ICON '(ssh)' + KUBERNETES_ICON $'\U2388' # ⎈ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -220,6 +222,7 @@ case $POWERLEVEL9K_MODE in LOCK_ICON $'\UF023' #  EXECUTION_TIME_ICON $'\uF252' #  SSH_ICON $'\uF489' #  + KUBERNETES_ICON $'\U2388' # ⎈ ) ;; *) @@ -288,6 +291,7 @@ case $POWERLEVEL9K_MODE in LOCK_ICON $'\UE0A2' EXECUTION_TIME_ICON 'Dur' SSH_ICON '(ssh)' + KUBERNETES_ICON $'\U2388' # ⎈ ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index fa2e94ab..0d794a85 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1362,7 +1362,7 @@ prompt_kubecontext() { local k8s_namespace=$(kubectl config get-contexts --no-headers | grep '*' | awk '{print $5}') # Get the current Kuberenetes context local k8s_context=$(kubectl config current-context) - "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_context/$k8s_namespace \u2388" + "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_context/$k8s_namespace" "KUBERNETES_ICON" fi } From 932e4edeaf5508a65e269e88668b588f2e6cac0f Mon Sep 17 00:00:00 2001 From: Jason Hutchinson Date: Fri, 26 May 2017 13:29:06 -0500 Subject: [PATCH 24/99] fix variable name typo --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0d794a85..d86dfe27 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1355,9 +1355,9 @@ prompt_dir_writable() { # Kubernetes Current Context prompt_kubecontext() { - local kubectl=$(kubectl version 2>/dev/null) + local kubectl_version=$(kubectl version 2>/dev/null) - if [[ -n "kubectl_version" ]]; then + if [[ -n "$kubectl_version" ]]; then # Get the current Kubernetes config context's namespaece local k8s_namespace=$(kubectl config get-contexts --no-headers | grep '*' | awk '{print $5}') # Get the current Kuberenetes context From 6f0c809a7dd81a277b7c1ec5bf9b7272ef9e3d7f Mon Sep 17 00:00:00 2001 From: Jason Hutchinson Date: Fri, 26 May 2017 13:34:11 -0500 Subject: [PATCH 25/99] empty namespace value is 'default' --- powerlevel9k.zsh-theme | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index d86dfe27..668748d2 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1362,6 +1362,10 @@ prompt_kubecontext() { local k8s_namespace=$(kubectl config get-contexts --no-headers | grep '*' | awk '{print $5}') # Get the current Kuberenetes context local k8s_context=$(kubectl config current-context) + + if [[ -z "$k8s_namespace" ]]; then + k8s_namespace="default" + fi "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_context/$k8s_namespace" "KUBERNETES_ICON" fi } From d2ecb38d60e31494ae808a08d9f338df6367cafb Mon Sep 17 00:00:00 2001 From: Jason Hutchinson Date: Fri, 26 May 2017 14:02:18 -0500 Subject: [PATCH 26/99] add tests --- test/segments/kubecontext.spec | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 test/segments/kubecontext.spec diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec new file mode 100755 index 00000000..eaaa2300 --- /dev/null +++ b/test/segments/kubecontext.spec @@ -0,0 +1,80 @@ +#!/usr/bin/env zsh +#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 + +# Required for shunit2 to run correctly +setopt shwordsplit +SHUNIT_PARENT=$0 + +function setUp() { + export TERM="xterm-256color" + # Load Powerlevel9k + source powerlevel9k.zsh-theme +} + +function mockKubectl() { + case "$1" in + 'version') + echo 'non-empty text' + ;; + 'config') + case "$2" in + 'current-context') + echo 'minikube' + ;; + 'get-contexts') + echo '* minikube minikube minikube ' + ;; + esac + ;; + esac +} + +function mockKubectlOtherNamespace() { + case "$1" in + 'version') + echo 'non-empty text' + ;; + 'config') + case "$2" in + 'current-context') + echo 'minikube' + ;; + 'get-contexts') + echo '* minikube minikube minikube kube-system' + ;; + esac + ;; + esac +} + +function testKubeContext() { + alias kubectl=mockKubectl + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) + + assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unalias kubectl +} +function testKubeContextOtherNamespace() { + alias kubectl=mockKubectlOtherNamespace + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) + + assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unalias kubectl +} +function testKubeContextPrintsNothingIfKubectlNotAvailable() { + alias kubectl=noKubectl + POWERLEVEL9K_CUSTOM_WORLD='echo world' + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world kubecontext) + + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_CUSTOM_WORLD + unalias kubectl +} + +source shunit2/source/2.1/src/shunit2 From ef0b5ce50fdd4be764d189723e6b51088fadc286 Mon Sep 17 00:00:00 2001 From: Jordan Taylor Date: Sun, 28 May 2017 12:57:30 -0400 Subject: [PATCH 27/99] add kubecontext test spec file to travis build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 134f31f1..e0ad5a93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,3 +28,4 @@ script: - test/segments/rust_version.spec - test/segments/go_version.spec - test/segments/vcs.spec + - test/segments/kubecontext.spec From 5eec2e28d0e44b2ac168fc3e08a38d68d4cb4fbe Mon Sep 17 00:00:00 2001 From: David Sabatie Date: Wed, 31 May 2017 17:32:42 +0200 Subject: [PATCH 28/99] add vpn ip to prompt --- README.md | 9 +++++++++ functions/icons.zsh | 16 ++++++++++------ powerlevel9k.zsh-theme | 11 +++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 890875ad..5b9cb24a 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ The segments that are currently available are: * `history` - The command number for the current line. * [`host`](#host) - Your current host name * [`ip`](#ip) - Shows the current IP address. +* [`vpn`](#vpn) - Shows the current VPN IP address. * [`public_ip`](#public_ip) - Shows your public IP address. * `load` - Your machine's load averages. * `os_icon` - Display a nice little icon, depending on your operating system. @@ -444,6 +445,14 @@ specify the correct network interface by setting: |----------|---------------|-------------| |`POWERLEVEL9K_IP_INTERFACE`|None|The NIC for which you wish to display the IP address. Example: `eth0`.| +##### vpn + +This segment tries to extract the VPN related IP addresses from nmcli, based on the NIC type: + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_VPN_IP_INTERFACE`|tun|The VPN NIC type| + ##### public_ip This segment will display your public IP address. There are several methods of obtaining this diff --git a/functions/icons.zsh b/functions/icons.zsh index 238b6b9e..9b5953e3 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -84,6 +84,7 @@ case $POWERLEVEL9K_MODE in LOCK_ICON $'\UE138' #  EXECUTION_TIME_ICON $'\UE89C' #  SSH_ICON '(ssh)' + VPN_ICON '(vpn)' ) ;; 'awesome-fontconfig') @@ -145,13 +146,14 @@ case $POWERLEVEL9K_MODE in VCS_GIT_GITLAB_ICON $'\uF296 ' #  VCS_HG_ICON $'\uF0C3 ' #  VCS_SVN_ICON '(svn) ' - RUST_ICON $'\uE6A8' #  + RUST_ICON $'\uE6A8' #  PYTHON_ICON $'\U1F40D' # 🐍 SWIFT_ICON '' PUBLIC_IP_ICON '' LOCK_ICON $'\UE138' #  EXECUTION_TIME_ICON $'\uF253' SSH_ICON '(ssh)' + VPN_ICON $'\uF023' ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -174,7 +176,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uF188' #  TODO_ICON $'\uF133' #  BATTERY_ICON $'\UF240 ' #  - DISK_ICON $'\uF0A0' #  + DISK_ICON $'\uF0A0' #  OK_ICON $'\uF00C' #  FAIL_ICON $'\uF00D' #  SYMFONY_ICON $'\uE757' #  @@ -210,16 +212,17 @@ case $POWERLEVEL9K_MODE in VCS_GIT_ICON $'\uF113 ' #  VCS_GIT_GITHUB_ICON $'\uE709 ' #  VCS_GIT_BITBUCKET_ICON $'\uE703 ' #  - VCS_GIT_GITLAB_ICON $'\uF296 ' #  + VCS_GIT_GITLAB_ICON $'\uF296 ' #  VCS_HG_ICON $'\uF0C3 ' #  VCS_SVN_ICON $'\uE72D ' #  RUST_ICON $'\uE7A8 ' #  PYTHON_ICON $'\UE73C ' #  SWIFT_ICON $'\uE755' #  PUBLIC_IP_ICON $'\UF0AC' #  - LOCK_ICON $'\UF023' #  - EXECUTION_TIME_ICON $'\uF252' #  - SSH_ICON $'\uF489' #  + LOCK_ICON $'\UF023' #  + EXECUTION_TIME_ICON $'\uF252' #  + SSH_ICON $'\uF489' #  + VPN_ICON '(vpn)' ) ;; *) @@ -288,6 +291,7 @@ case $POWERLEVEL9K_MODE in LOCK_ICON $'\UE0A2' EXECUTION_TIME_ICON 'Dur' SSH_ICON '(ssh)' + VPN_ICON '(vpn)' ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 666ce965..760de5a9 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -914,6 +914,17 @@ prompt_ip() { "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' } +set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" +# prompt if vpn active +prompt_vpn_ip() { + for vpn_iface in $(ip tuntap | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) + do + ip=$(ip -4 a show "$vpn_iface" | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*") + "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' + done +} + + prompt_load() { # The load segment can have three different states local current_state="unknown" From d6a14a9a010009866c60a2f4d52d0aefac93e876 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 2 Jun 2017 11:59:30 -0400 Subject: [PATCH 29/99] Updating README and CHANGELOG --- CHANGELOG.md | 22 ++++++++++++++++++++++ README.md | 1 + 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d6ecd18..0355c464 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +## Next + +- Added `teardown` command to turn off P9k prompt. +- Fixes for P9k in Cygwin and 32-bit systems. +- Better colors in virtualization segments. +- Added 'Gopher' icon to the `go_version` segment. +- Improved detection in `nvm` +- Added option to support command status reading from piped command sequences. + +### New Segments: `host` and `user` + +Provides two separate segments for `host` and `user` in case you don't wont both +in one (per the `context` segment). + +### New Segment: `newline` + +Allows you to split segments across multiple lines. + +### New Segment: `kubecontext` + +Shows the current context of your `kubectl` configuration. + ## v0.6.4 - Significant enhancements to the `battery` segment. Check out the README to diff --git a/README.md b/README.md index 890875ad..678cf0b9 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ The segments that are currently available are: * [`aws`](#aws) - The current AWS profile, if active. * `aws_eb_env` - The current Elastic Beanstalk Environment. * `docker_machine` - The current Docker Machine. +* `kubecontext` - The current context of your `kubectl` configuration. **Other:** * [`custom_command`](#custom_command) - Create a custom segment to display the From 70e0b207729115536cc5e14ce02e051b9819814b Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 2 Jun 2017 12:14:07 -0400 Subject: [PATCH 30/99] Updating CHANGELOG with new `vpn` segment --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0355c464..8dd7a4a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ Allows you to split segments across multiple lines. Shows the current context of your `kubectl` configuration. +### New Segment: `vpn` + +Shows current `vpn` address. + ## v0.6.4 - Significant enhancements to the `battery` segment. Check out the README to From 3c3a86a42f6299f8ccc9af27b4cb03467cb28927 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 2 Jun 2017 12:15:38 -0400 Subject: [PATCH 31/99] Fixes for README and CHANGELOG re: `vpn` segment. --- CHANGELOG.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dd7a4a5..42120aea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ Shows the current context of your `kubectl` configuration. ### New Segment: `vpn` -Shows current `vpn` address. +Shows current `vpn` interface. ## v0.6.4 diff --git a/README.md b/README.md index b03bee48..f885f877 100644 --- a/README.md +++ b/README.md @@ -452,7 +452,7 @@ This segment tries to extract the VPN related IP addresses from nmcli, based on | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_VPN_IP_INTERFACE`|tun|The VPN NIC type| +|`POWERLEVEL9K_VPN_IP_INTERFACE`|`tun`|The VPN interface.| ##### public_ip From 9a3d2e4ca14897c98f5215c5961a1a3cfd214da2 Mon Sep 17 00:00:00 2001 From: David Sabatie Date: Sat, 3 Jun 2017 20:11:24 +0200 Subject: [PATCH 32/99] vpn prompt: change "ip" to "ifconfig" to be used on OSX --- powerlevel9k.zsh-theme | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index dc7f0388..5058e3b6 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -917,14 +917,13 @@ prompt_ip() { set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" # prompt if vpn active prompt_vpn_ip() { - for vpn_iface in $(ip tuntap | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) do - ip=$(ip -4 a show "$vpn_iface" | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*") + ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2) "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' done } - prompt_load() { # The load segment can have three different states local current_state="unknown" From 65c770606b621a9d1cf809345f7baac6c800ff2a Mon Sep 17 00:00:00 2001 From: Pavel Peganov Date: Sun, 11 Jun 2017 04:09:00 +0300 Subject: [PATCH 33/99] Fixed RVM segment for usernames with dashes Having a username with a dash, such as mine, `d-side`, currently results in RVM segment displaying the wrong thing, e. g. `side/.rvm/rubies/ruby`. This fixes the issue. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 26ab9cd5..657d691d 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -990,7 +990,7 @@ prompt_rvm() { local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') [ "$gemset" != "" ] && gemset="@$gemset" - local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') + local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $NF}') if [[ -n "$version$gemset" ]]; then "$1_prompt_segment" "$0" "$2" "240" "$DEFAULT_COLOR" "$version$gemset" 'RUBY_ICON' From 3dddcf519d2df2164a918a9b64b71510633932b6 Mon Sep 17 00:00:00 2001 From: Derek Bassett Date: Mon, 26 Jun 2017 13:51:41 -0600 Subject: [PATCH 34/99] Resolves issue #553 where prompt hangs on kubectl version. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index dc7f0388..534a5892 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1366,7 +1366,7 @@ prompt_dir_writable() { # Kubernetes Current Context prompt_kubecontext() { - local kubectl_version=$(kubectl version 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 3bf0f18e266be2a6582736f3e2270bd0d0bc6afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Sat, 8 Jul 2017 01:07:40 -0400 Subject: [PATCH 35/99] Cleaned up installation directory detection - Used ZSH built-in magic to get the installation directory. - Works with symlinks. - No longer calls out to external program 'dirname'. - Fixed issue with spaces in the path. - No longer leak the variables 'filename' and 'script_location'. --- powerlevel9k.zsh-theme | 67 ++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 42 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index dc7f0388..3773b727 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -17,74 +17,57 @@ ################################################################ ## Turn on for Debugging +#PS4='%s%f%b%k%F{blue}%{λ%}%L %F{240}%N:%i%(?.. %F{red}%?) %1(_.%F{yellow}%-1_ .)%s%f%b%k ' #zstyle ':vcs_info:*+*:*' debug true #set -o xtrace # Try to set the installation path -if [[ -n "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then - # If an installation path was set manually, - # it should trump any other location found. - # Do nothing. This is all right, as we use the - # POWERLEVEL9K_INSTALLATION_PATH for further processing. -elif [[ $(whence -w prompt_powerlevel9k_setup) =~ "function" ]]; then - # Check if the theme was called as a function (e.g., from prezto) - autoload -U is-at-least - if is-at-least 5.0.8; then - # Try to find the correct path of the script. - POWERLEVEL9K_INSTALLATION_PATH=$(whence -v $0 | sed "s/$0 is a shell function from //") - elif [[ -f "${ZDOTDIR:-$HOME}/.zprezto/modules/prompt/init.zsh" ]]; then - # If there is an prezto installation, we assume that powerlevel9k is linked there. - POWERLEVEL9K_INSTALLATION_PATH="${ZDOTDIR:-$HOME}/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup" - fi +if [[ -n "$POWERLEVEL9K_INSTALLATION_DIR" ]]; then + p9k_directory=${POWERLEVEL9K_INSTALLATION_DIR:A} else - # Last resort: Set installation path is script path - POWERLEVEL9K_INSTALLATION_PATH="$0" -fi - -# Resolve the installation path -if [[ -L "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then - # If this theme is sourced as a symlink, we need to locate the real URL - filename="${POWERLEVEL9K_INSTALLATION_PATH:A}" -elif [[ -d "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then - # Directory - filename="${POWERLEVEL9K_INSTALLATION_PATH}/powerlevel9k.zsh-theme" -elif [[ -f "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then - # Script is a file - filename="$POWERLEVEL9K_INSTALLATION_PATH" -elif [[ -z "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then - # Fallback: specify an installation path! - print -P "%F{red}We could not locate the installation path of powerlevel9k.%f" - print -P "Please specify by setting %F{blue}POWERLEVEL9K_INSTALLATION_PATH%f (full path incl. file name) at the very beginning of your ~/.zshrc" - return 1 -else - print -P "%F{red}Script location could not be found! Maybe your %F{blue}POWERLEVEL9K_INSTALLATION_PATH%F{red} is not correct?%f" - return 1 + if [[ "${(%):-%N}" == '(eval)' ]]; then + if [[ "$0" == '-antigen-load' ]] && [[ -r "${PWD}/powerlevel9k.zsh-theme" ]]; then + # Antigen uses eval to load things so it can change the plugin (!!) + # https://github.com/zsh-users/antigen/issues/581 + p9k_directory=$PWD + else + print -P "%F{red}You must set POWERLEVEL9K_INSTALLATION_DIR work from within an (eval).%f" + return 1 + fi + else + # Get the path to file this code is executing in; then + # get the absolute path and strip the filename. + # See https://stackoverflow.com/a/28336473/108857 + p9k_directory=${${(%):-%x}:A:h} + fi fi -script_location="$(dirname $filename)" ################################################################ # Source icon functions ################################################################ -source $script_location/functions/icons.zsh +source "${p9k_directory}/functions/icons.zsh" ################################################################ # Source utility functions ################################################################ -source $script_location/functions/utilities.zsh +source "${p9k_directory}/functions/utilities.zsh" ################################################################ # Source color functions ################################################################ -source $script_location/functions/colors.zsh +source "${p9k_directory}/functions/colors.zsh" ################################################################ # Source VCS_INFO hooks / helper functions ################################################################ -source $script_location/functions/vcs.zsh +source "${p9k_directory}/functions/vcs.zsh" + +# cleanup temporary variables. +unset p9k_directory ################################################################ # Color Scheme From df318488c9bad0fae2e38c8fd57afaade295f135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Mon, 10 Jul 2017 18:39:55 -0400 Subject: [PATCH 36/99] test-in-docker: quickly test frameworks in docker This adds `./test-in-docker` for quickly playing with various frameworks. All the containers are based off Ubuntu 14.04 which has ZSH 5.0.2. Thanks to @dritter for figuring out all the framework installation methods. --- TESTS.md | 19 ++++++-- docker/antibody/Dockerfile | 7 +++ docker/antibody/install.zsh | 1 + docker/antibody/zshrc | 2 + docker/antigen/Dockerfile | 7 +++ docker/antigen/install.zsh | 12 +++++ docker/antigen/zshrc | 4 ++ docker/base/Dockerfile | 33 ++++++++++++++ docker/dotfile/Dockerfile | 4 ++ docker/dotfile/zshrc | 1 + docker/fred-sudoers | 2 + docker/omz/Dockerfile | 7 +++ docker/omz/install.zsh | 4 ++ docker/omz/zshrc | 5 +++ docker/prezto/Dockerfile | 6 +++ docker/prezto/install.zsh | 18 ++++++++ docker/zgen/Dockerfile | 7 +++ docker/zgen/install.zsh | 5 +++ docker/zgen/zshrc | 10 +++++ docker/zim/Dockerfile | 6 +++ docker/zim/install.zsh | 21 +++++++++ docker/zplug/Dockerfile | 7 +++ docker/zplug/install.zsh | 5 +++ docker/zplug/zshrc | 5 +++ docker/zplugin/Dockerfile | 7 +++ docker/zplugin/install.zsh | 12 +++++ docker/zplugin/zshrc.plugins | 5 +++ docker/zpm/Dockerfile | 7 +++ docker/zpm/install.zsh | 6 +++ docker/zpm/zshrc | 3 ++ docker/zulu/Dockerfile | 6 +++ docker/zulu/install.zsh | 10 +++++ test-in-docker | 85 ++++++++++++++++++++++++++++++++++++ 33 files changed, 336 insertions(+), 3 deletions(-) create mode 100644 docker/antibody/Dockerfile create mode 100644 docker/antibody/install.zsh create mode 100644 docker/antibody/zshrc create mode 100644 docker/antigen/Dockerfile create mode 100644 docker/antigen/install.zsh create mode 100644 docker/antigen/zshrc create mode 100644 docker/base/Dockerfile create mode 100644 docker/dotfile/Dockerfile create mode 100644 docker/dotfile/zshrc create mode 100644 docker/fred-sudoers create mode 100644 docker/omz/Dockerfile create mode 100644 docker/omz/install.zsh create mode 100644 docker/omz/zshrc create mode 100644 docker/prezto/Dockerfile create mode 100644 docker/prezto/install.zsh create mode 100644 docker/zgen/Dockerfile create mode 100644 docker/zgen/install.zsh create mode 100644 docker/zgen/zshrc create mode 100644 docker/zim/Dockerfile create mode 100644 docker/zim/install.zsh create mode 100644 docker/zplug/Dockerfile create mode 100644 docker/zplug/install.zsh create mode 100644 docker/zplug/zshrc create mode 100644 docker/zplugin/Dockerfile create mode 100644 docker/zplugin/install.zsh create mode 100644 docker/zplugin/zshrc.plugins create mode 100644 docker/zpm/Dockerfile create mode 100644 docker/zpm/install.zsh create mode 100644 docker/zpm/zshrc create mode 100644 docker/zulu/Dockerfile create mode 100644 docker/zulu/install.zsh create mode 100755 test-in-docker diff --git a/TESTS.md b/TESTS.md index d51051c5..64c4db48 100644 --- a/TESTS.md +++ b/TESTS.md @@ -13,10 +13,23 @@ Tests in separate files under `test/functions`. These Tests tend to be more complex in setup than the basic tests. To avoid ending up in a huge single file, there is one file per segment in `test/segments`. -# Test-VMs +# Manual Testing If unit tests are not sufficient (e.g. you have an issue with your prompt that -occurs only in a specific ZSH framework), then you could use our Test-VMs! +occurs only in a specific ZSH framework) then you can use either Docker or +or our Vagrant. + +## Docker + +This is the easiest to use _if_ you have Docker already installed and running. + +The command `./test-in-docker` should make it fairly easy to get into a running +container with the framework of your choice. + +You can get Docker at . + +## Vagrant + Currently there are two test VMs. `test-vm` is an Ubuntu machine with several pre-installed ZSH frameworks. And there is `test-bsd-vm` which is a FreeBSD! -For how to run the machines see [here](test-vm/README.md). \ No newline at end of file +For how to run the machines see [here](test-vm/README.md). diff --git a/docker/antibody/Dockerfile b/docker/antibody/Dockerfile new file mode 100644 index 00000000..9ee2e8be --- /dev/null +++ b/docker/antibody/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/antibody/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/antibody/zshrc .zshrc diff --git a/docker/antibody/install.zsh b/docker/antibody/install.zsh new file mode 100644 index 00000000..4c54fa68 --- /dev/null +++ b/docker/antibody/install.zsh @@ -0,0 +1 @@ +curl -sL https://git.io/antibody | bash -s diff --git a/docker/antibody/zshrc b/docker/antibody/zshrc new file mode 100644 index 00000000..d516b679 --- /dev/null +++ b/docker/antibody/zshrc @@ -0,0 +1,2 @@ +source <(antibody init) +antibody bundle ~/p9k/ diff --git a/docker/antigen/Dockerfile b/docker/antigen/Dockerfile new file mode 100644 index 00000000..76487678 --- /dev/null +++ b/docker/antigen/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/antigen/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/antigen/zshrc .zshrc diff --git a/docker/antigen/install.zsh b/docker/antigen/install.zsh new file mode 100644 index 00000000..6bab8ab3 --- /dev/null +++ b/docker/antigen/install.zsh @@ -0,0 +1,12 @@ +#!/bin/zsh + +mkdir ~/antigen + +curl \ + -qLsSf \ + -o ~/antigen/antigen.zsh \ + https://git.io/antigen + +source ~/antigen/antigen.zsh + +# EOF diff --git a/docker/antigen/zshrc b/docker/antigen/zshrc new file mode 100644 index 00000000..0f8d4da4 --- /dev/null +++ b/docker/antigen/zshrc @@ -0,0 +1,4 @@ +source ~/antigen/antigen.zsh + +antigen theme "${HOME}/p9k" powerlevel9k --no-local-clone +antigen apply diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 00000000..08d06254 --- /dev/null +++ b/docker/base/Dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:trusty + +RUN \ + apt-get update && \ + echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + node \ + ruby \ + python \ + python-virtualenv + +RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred +RUN locale-gen "en_US.UTF-8" + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/docker/dotfile/Dockerfile b/docker/dotfile/Dockerfile new file mode 100644 index 00000000..166e348c --- /dev/null +++ b/docker/dotfile/Dockerfile @@ -0,0 +1,4 @@ +FROM p9k:base + +COPY ./ p9k/ +COPY docker/dotfile/zshrc .zshrc diff --git a/docker/dotfile/zshrc b/docker/dotfile/zshrc new file mode 100644 index 00000000..382b84a8 --- /dev/null +++ b/docker/dotfile/zshrc @@ -0,0 +1 @@ +source "${HOME}/p9k/prompt_powerlevel9k_setup" diff --git a/docker/fred-sudoers b/docker/fred-sudoers new file mode 100644 index 00000000..5fcd646f --- /dev/null +++ b/docker/fred-sudoers @@ -0,0 +1,2 @@ +Defaults:fred !requiretty +fred ALL=(ALL) NOPASSWD: ALL diff --git a/docker/omz/Dockerfile b/docker/omz/Dockerfile new file mode 100644 index 00000000..f839fba8 --- /dev/null +++ b/docker/omz/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/omz/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY docker/omz/zshrc .zshrc +COPY ./ p9k/ diff --git a/docker/omz/install.zsh b/docker/omz/install.zsh new file mode 100644 index 00000000..e2cdfa96 --- /dev/null +++ b/docker/omz/install.zsh @@ -0,0 +1,4 @@ +sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" + +mkdir -p ~/.oh-my-zsh/custom/themes +ln -nsf ~/p9k/ ~/.oh-my-zsh/custom/themes/powerlevel9k diff --git a/docker/omz/zshrc b/docker/omz/zshrc new file mode 100644 index 00000000..9e798e2d --- /dev/null +++ b/docker/omz/zshrc @@ -0,0 +1,5 @@ +export ZSH=$HOME/.oh-my-zsh +ZSH_THEME="powerlevel9k/powerlevel9k" +plugins=(git rake ruby) + +source $ZSH/oh-my-zsh.sh diff --git a/docker/prezto/Dockerfile b/docker/prezto/Dockerfile new file mode 100644 index 00000000..389dbd0a --- /dev/null +++ b/docker/prezto/Dockerfile @@ -0,0 +1,6 @@ +FROM p9k:base + +COPY docker/prezto/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ diff --git a/docker/prezto/install.zsh b/docker/prezto/install.zsh new file mode 100644 index 00000000..9cca57ed --- /dev/null +++ b/docker/prezto/install.zsh @@ -0,0 +1,18 @@ +#!/bin/zsh + +set -eu + +git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" + +setopt EXTENDED_GLOB +for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do + ln -nsf "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" +done + +ln -s "${HOME}/p9k/powerlevel9k.zsh-theme" \ + "${HOME}/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup" + +echo "zstyle ':prezto:module:prompt' theme 'powerlevel9k'" \ + >> "${HOME}/.zpreztorc" + +# EOF diff --git a/docker/zgen/Dockerfile b/docker/zgen/Dockerfile new file mode 100644 index 00000000..9a0c13c7 --- /dev/null +++ b/docker/zgen/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/zgen/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zgen/zshrc .zshrc diff --git a/docker/zgen/install.zsh b/docker/zgen/install.zsh new file mode 100644 index 00000000..5cdc6181 --- /dev/null +++ b/docker/zgen/install.zsh @@ -0,0 +1,5 @@ +#!/bin/zsh + +git clone https://github.com/tarjoilija/zgen.git "${HOME}/.zgen" + +# EOF diff --git a/docker/zgen/zshrc b/docker/zgen/zshrc new file mode 100644 index 00000000..1fcb75b9 --- /dev/null +++ b/docker/zgen/zshrc @@ -0,0 +1,10 @@ +# load zgen +source ~/.zgen/zgen.zsh + +# if the init scipt doesn't exist +if ! zgen saved; then + zgen load ~/p9k/powerlevel9k.zsh-theme + + # generate the init script from plugins above + zgen save +fi diff --git a/docker/zim/Dockerfile b/docker/zim/Dockerfile new file mode 100644 index 00000000..dd10d102 --- /dev/null +++ b/docker/zim/Dockerfile @@ -0,0 +1,6 @@ +FROM p9k:base + +COPY docker/zim/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ diff --git a/docker/zim/install.zsh b/docker/zim/install.zsh new file mode 100644 index 00000000..d6c6006a --- /dev/null +++ b/docker/zim/install.zsh @@ -0,0 +1,21 @@ +#!zsh + +git clone --recursive https://github.com/Eriner/zim.git "${ZDOTDIR:-${HOME}}/.zim" + +setopt EXTENDED_GLOB +for template_file ( ${ZDOTDIR:-${HOME}}/.zim/templates/* ); do + user_file="${ZDOTDIR:-${HOME}}/.${template_file:t}" + touch ${user_file} + ( print -rn "$(<${template_file})$(<${user_file})" >! ${user_file} ) 2>/dev/null +done + +source "${ZDOTDIR:-${HOME}}/.zlogin" + +ln -nsf \ + ~/p9k/ \ + ~/.zim/modules/prompt/external-themes/powerlevel9k +ln -nsf \ + ~/.zim/modules/prompt/external-themes/powerlevel9k/powerlevel9k.zsh-theme \ + ~/.zim/modules/prompt/functions/prompt_powerlevel9k_setup + +sed -i "s/zprompt_theme='steeef'/zprompt_theme='powerlevel9k'/g" ~/.zimrc diff --git a/docker/zplug/Dockerfile b/docker/zplug/Dockerfile new file mode 100644 index 00000000..a87480be --- /dev/null +++ b/docker/zplug/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/zplug/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zplug/zshrc .zshrc diff --git a/docker/zplug/install.zsh b/docker/zplug/install.zsh new file mode 100644 index 00000000..b01ff6ee --- /dev/null +++ b/docker/zplug/install.zsh @@ -0,0 +1,5 @@ +#!zsh + +curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh| zsh + +# git clone https://github.com/zplug/zplug "${HOME}/.zplug" diff --git a/docker/zplug/zshrc b/docker/zplug/zshrc new file mode 100644 index 00000000..0a4ceb83 --- /dev/null +++ b/docker/zplug/zshrc @@ -0,0 +1,5 @@ +#!zsh + +source ~/.zplug/init.zsh +zplug "${HOME}/p9k", use:"powerlevel9k.zsh-theme", from:local, as:theme +zplug load --verbose diff --git a/docker/zplugin/Dockerfile b/docker/zplugin/Dockerfile new file mode 100644 index 00000000..dc723606 --- /dev/null +++ b/docker/zplugin/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/zplugin/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zplugin/zshrc.plugins .zshrc.plugins diff --git a/docker/zplugin/install.zsh b/docker/zplugin/install.zsh new file mode 100644 index 00000000..fec4249d --- /dev/null +++ b/docker/zplugin/install.zsh @@ -0,0 +1,12 @@ +sh -c "$(curl -fsSL https://raw.githubusercontent.com/psprint/zplugin/master/doc/install.sh)" + +# The 'zplugin snippet' only copies the .zsh-theme file, not everything else. +mkdir -p ~/.zplugin/snippets +ln -nsf \ + ~/p9k/ \ +~/.zplugin/snippets/--SLASH--home--SLASH--fred--SLASH--p9k--SLASH--powerlevel9k--DOT--zsh-theme + +{ + echo + echo "source ~/.zshrc.plugins" +} >> ~/.zshrc diff --git a/docker/zplugin/zshrc.plugins b/docker/zplugin/zshrc.plugins new file mode 100644 index 00000000..2e9ba7a3 --- /dev/null +++ b/docker/zplugin/zshrc.plugins @@ -0,0 +1,5 @@ +#!zsh + +zplugin load psprint zsh-navigation-tools +zplugin load psprint---zprompts +zplugin snippet ~/p9k/powerlevel9k.zsh-theme diff --git a/docker/zpm/Dockerfile b/docker/zpm/Dockerfile new file mode 100644 index 00000000..d99edb37 --- /dev/null +++ b/docker/zpm/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/zpm/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zpm/zshrc .zshrc diff --git a/docker/zpm/install.zsh b/docker/zpm/install.zsh new file mode 100644 index 00000000..6f74e8e0 --- /dev/null +++ b/docker/zpm/install.zsh @@ -0,0 +1,6 @@ +# install zpm +git clone --recursive https://github.com/zpm-zsh/zpm.git ~/.zpm + +# Install powerlevel9k +mkdir ~/.zpm/plugins/powerlevel9k +ln -s ~/p9k/powerlevel9k.zsh-theme ~/.zpm/plugins/powerlevel9k/powerlevel9k.plugin.zsh diff --git a/docker/zpm/zshrc b/docker/zpm/zshrc new file mode 100644 index 00000000..b107976e --- /dev/null +++ b/docker/zpm/zshrc @@ -0,0 +1,3 @@ +source ~/.zpm/zpm.zsh + +zpm load powerlevel9k diff --git a/docker/zulu/Dockerfile b/docker/zulu/Dockerfile new file mode 100644 index 00000000..dcb332ab --- /dev/null +++ b/docker/zulu/Dockerfile @@ -0,0 +1,6 @@ +FROM p9k:base + +COPY docker/zulu/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ diff --git a/docker/zulu/install.zsh b/docker/zulu/install.zsh new file mode 100644 index 00000000..0ad6aae3 --- /dev/null +++ b/docker/zulu/install.zsh @@ -0,0 +1,10 @@ +#!zsh + +# install zulu https://github.com/zulu-zsh/zulu +curl -L https://git.io/zulu-install | zsh && zsh + +{ +echo 'zulu fpath add ~/p9k' +echo 'zulu fpath add ~/p9k/functions' +echo 'zulu theme powerlevel9k' +} >> ~/.zshrc diff --git a/test-in-docker b/test-in-docker new file mode 100755 index 00000000..ff3bb86b --- /dev/null +++ b/test-in-docker @@ -0,0 +1,85 @@ +#!/usr/bin/env zsh + +set -eu + +setopt extendedglob +cd "${${(%):-%x}:A:h}" + +# TODO: Crazy Logic to munge TERM to something supported in Ubuntu 14.04 +term=screen-256color + +frameworks() +{ + for path in docker/*/Dockerfile(N.); do + framework=${path:h:t} + if [[ "$framework" == base ]]; then continue; fi + echo "$framework" + done +} + +show-help() +{ + echo "Usage: ${(%):-%x} |--list" + echo + echo "Loads up a docker image with powershell9k configured in " + echo + echo " --list Lists all available framework containers." + echo + echo "Framework containers:" + for f in $(frameworks); do + echo " - $f" + done +} + +build-and-run() +{ + local framework="$1" ; shift + + print -P "%F{green}Preparing ${framework} container...%f" + + if [[ "$framework" != "base" ]]; then + echo -n "p9k:base: " + docker build \ + --quiet \ + --tag p9k:base \ + --file docker/base/Dockerfile \ + . + fi + echo -n "p9k:${framework}: " + docker build \ + --quiet \ + --tag "p9k:${framework}" \ + --file "docker/${framework}/Dockerfile" \ + . + + + print -P "%F{green}Starting ${framework} container...%f" + exec docker run \ + --rm \ + --interactive \ + --tty \ + --hostname="${framework}" \ + --env="TERM=${term}" \ + "$@" \ + "p9k:${framework}" +} + +arg1="${1:-}"; if (( $# > 0 )); then shift; fi + +if [[ -z "$arg1" ]] || [[ "$arg1" == "help" ]]; then + show-help + exit 0 +elif [[ "$arg1" == '--list' ]]; then + frameworks + exit 0 +elif [[ -d "docker/${arg1}" ]]; then + build-and-run "$arg1" +elif [[ -n "docker/${arg1}"*/Dockerfile(#qN) ]]; then + # Allow globbing + build-and-run "docker/${arg1}"*(Y1:t) +else + show-help + exit 1 +fi + +# EOF From a234636982349a82ab6c7f0674f3ff884acddc94 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 12 Jul 2017 03:29:31 +0200 Subject: [PATCH 37/99] Fix empty delimiter Even if the delimiter is empty, the min length should be 1. This fixes #558 --- functions/utilities.zsh | 2 +- test/segments/dir.spec | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 86e5ba0e..39c5ecae 100644 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -212,7 +212,7 @@ function segmentShouldBeJoined() { # Given a directory path, truncate it according to the settings for # `truncate_from_right` function truncatePathFromRight() { - local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER} + local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER:-1} echo $1 | sed $SED_EXTENDED_REGEX_PARAMETER \ "s@(([^/]{$((POWERLEVEL9K_SHORTEN_DIR_LENGTH))})([^/]{$delim_len}))[^/]+/@\2$POWERLEVEL9K_SHORTEN_DELIMITER/@g" } diff --git a/test/segments/dir.spec b/test/segments/dir.spec index b2991175..3a6af649 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -72,6 +72,26 @@ function testTruncationFromRightWorks() { unset POWERLEVEL9K_SHORTEN_STRATEGY } +function testTruncationFromRightWithEmptyDelimiter() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_DELIMITER="" + POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' + + FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + mkdir -p $FOLDER + cd $FOLDER + + assertEquals "%K{blue} %F{black}/tmp/po/1/12/123/12/12/12/12/12/123456789 %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset FOLDER + unset POWERLEVEL9K_SHORTEN_DIR_LENGTH + unset POWERLEVEL9K_SHORTEN_DELIMITER + unset POWERLEVEL9K_SHORTEN_STRATEGY +} + function testTruncateWithFolderMarkerWorks() { POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" From 0fded47ab587a28e4656b95dff39340d204f28d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Wed, 12 Jul 2017 00:48:35 -0400 Subject: [PATCH 38/99] Added test for POWERLEVEL9K_HOME_FOLDER_ABBREVIATION --- test/segments/dir.spec | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/segments/dir.spec b/test/segments/dir.spec index b2991175..f4842f38 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -272,6 +272,31 @@ function testChangingDirPathSeparator() { unset POWERLEVEL9K_DIR_PATH_SEPARATOR } +function testHomeFolderAbbreviation() { + local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION + local dir=$PWD + + cd ~/ + # default + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' + assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + + # substituted + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' + assertEquals "%K{blue} %F{black}qQq %k%F{blue}%f " "$(build_left_prompt)" + + cd /tmp + # default + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' + assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + + # substituted + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' + assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + + cd "$dir" +} + function testOmittingFirstCharacterWorks() { POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true POWERLEVEL9K_FOLDER_ICON='folder-icon' From aca0f31eb00df91a2b40ac6baea8efb64bd84cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Wed, 12 Jul 2017 01:02:46 -0400 Subject: [PATCH 39/99] Replaced a sed call with pure ZSH --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 534a5892..2e8c30bb 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -811,7 +811,7 @@ prompt_dir() { fi if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" ]]; then - current_path="$( echo "${current_path}" | sed "s/^~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}/")" + current_path=${current_path/#\~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}} fi typeset -AH dir_states From 2f808f8a4e6224478e1c9efb85c1a4b3f24df087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Wed, 12 Jul 2017 02:46:32 -0400 Subject: [PATCH 40/99] test-in-docker: Support for multiple ZSH versions -z --zsh can specify one of the versions of ZSH we can get from centos and ubuntu --- TESTS.md | 14 ++ docker/antibody/Dockerfile | 3 +- docker/antigen/Dockerfile | 3 +- docker/base-4.3.11/Dockerfile | 31 +++++ docker/{base => base-5.0.3}/Dockerfile | 2 +- docker/base-5.1.1/Dockerfile | 35 +++++ docker/base-5.2/Dockerfile | 35 +++++ docker/dotfile/Dockerfile | 3 +- docker/omz/Dockerfile | 3 +- docker/prezto/Dockerfile | 3 +- docker/zgen/Dockerfile | 3 +- docker/zim/Dockerfile | 3 +- docker/zplug/Dockerfile | 3 +- docker/zplugin/Dockerfile | 3 +- docker/zpm/Dockerfile | 3 +- docker/zulu/Dockerfile | 3 +- test-in-docker | 180 +++++++++++++++++-------- 17 files changed, 264 insertions(+), 66 deletions(-) create mode 100644 docker/base-4.3.11/Dockerfile rename docker/{base => base-5.0.3}/Dockerfile (96%) create mode 100644 docker/base-5.1.1/Dockerfile create mode 100644 docker/base-5.2/Dockerfile diff --git a/TESTS.md b/TESTS.md index 64c4db48..eb5db704 100644 --- a/TESTS.md +++ b/TESTS.md @@ -26,8 +26,22 @@ This is the easiest to use _if_ you have Docker already installed and running. The command `./test-in-docker` should make it fairly easy to get into a running container with the framework of your choice. +Examples: + +``` zsh +# Test Antigen with the oldest version of ZSH +$ ./test-in-docker antigen +``` + +``` zsh +# Test Prezto with ZSH version 5.2 +$ ./test-in-docker --zsh 5.2 prezto +``` + You can get Docker at . +**Note:** Not all frameworks work with all versions of ZSH (or the underlying OS). + ## Vagrant Currently there are two test VMs. `test-vm` is an Ubuntu machine with several diff --git a/docker/antibody/Dockerfile b/docker/antibody/Dockerfile index 9ee2e8be..84a60a89 100644 --- a/docker/antibody/Dockerfile +++ b/docker/antibody/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/antibody/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/antigen/Dockerfile b/docker/antigen/Dockerfile index 76487678..d8d0a4bc 100644 --- a/docker/antigen/Dockerfile +++ b/docker/antigen/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/antigen/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/base-4.3.11/Dockerfile b/docker/base-4.3.11/Dockerfile new file mode 100644 index 00000000..805a7ae1 --- /dev/null +++ b/docker/base-4.3.11/Dockerfile @@ -0,0 +1,31 @@ +FROM centos:6 + +RUN \ + yum install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + node \ + ruby \ + python \ + python-virtualenv \ + sudo + +RUN adduser --shell /bin/zsh --comment 'fred' --user-group fred + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/docker/base/Dockerfile b/docker/base-5.0.3/Dockerfile similarity index 96% rename from docker/base/Dockerfile rename to docker/base-5.0.3/Dockerfile index 08d06254..e0b6c6c3 100644 --- a/docker/base/Dockerfile +++ b/docker/base-5.0.3/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:trusty +FROM ubuntu:14.04 RUN \ apt-get update && \ diff --git a/docker/base-5.1.1/Dockerfile b/docker/base-5.1.1/Dockerfile new file mode 100644 index 00000000..a7f644bf --- /dev/null +++ b/docker/base-5.1.1/Dockerfile @@ -0,0 +1,35 @@ +FROM ubuntu:16.04 + +RUN \ + apt-get update && \ + echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + nodejs \ + ruby \ + python \ + python-virtualenv \ + sudo \ + locales + +RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred +RUN locale-gen "en_US.UTF-8" + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/docker/base-5.2/Dockerfile b/docker/base-5.2/Dockerfile new file mode 100644 index 00000000..62a10074 --- /dev/null +++ b/docker/base-5.2/Dockerfile @@ -0,0 +1,35 @@ +FROM ubuntu:17.04 + +RUN \ + apt-get update && \ + echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + nodejs \ + ruby \ + python \ + python-virtualenv \ + sudo \ + locales + +RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred +RUN locale-gen "en_US.UTF-8" + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/docker/dotfile/Dockerfile b/docker/dotfile/Dockerfile index 166e348c..f29c4d56 100644 --- a/docker/dotfile/Dockerfile +++ b/docker/dotfile/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY ./ p9k/ COPY docker/dotfile/zshrc .zshrc diff --git a/docker/omz/Dockerfile b/docker/omz/Dockerfile index f839fba8..1a417b9f 100644 --- a/docker/omz/Dockerfile +++ b/docker/omz/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/omz/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/prezto/Dockerfile b/docker/prezto/Dockerfile index 389dbd0a..70f3b65d 100644 --- a/docker/prezto/Dockerfile +++ b/docker/prezto/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/prezto/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zgen/Dockerfile b/docker/zgen/Dockerfile index 9a0c13c7..48e44c77 100644 --- a/docker/zgen/Dockerfile +++ b/docker/zgen/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zgen/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zim/Dockerfile b/docker/zim/Dockerfile index dd10d102..cfe0fc93 100644 --- a/docker/zim/Dockerfile +++ b/docker/zim/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zim/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zplug/Dockerfile b/docker/zplug/Dockerfile index a87480be..89c23d54 100644 --- a/docker/zplug/Dockerfile +++ b/docker/zplug/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zplug/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zplugin/Dockerfile b/docker/zplugin/Dockerfile index dc723606..90c35c0e 100644 --- a/docker/zplugin/Dockerfile +++ b/docker/zplugin/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zplugin/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zpm/Dockerfile b/docker/zpm/Dockerfile index d99edb37..c1c44e38 100644 --- a/docker/zpm/Dockerfile +++ b/docker/zpm/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zpm/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zulu/Dockerfile b/docker/zulu/Dockerfile index dcb332ab..880a07d0 100644 --- a/docker/zulu/Dockerfile +++ b/docker/zulu/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zulu/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/test-in-docker b/test-in-docker index ff3bb86b..c1aafcd9 100755 --- a/test-in-docker +++ b/test-in-docker @@ -2,84 +2,156 @@ set -eu -setopt extendedglob +# The default ZSH to use. +default_version='4.3.11' + +setopt extended_glob glob_subst numeric_glob_sort cd "${${(%):-%x}:A:h}" # TODO: Crazy Logic to munge TERM to something supported in Ubuntu 14.04 term=screen-256color -frameworks() +# Note: If versions and frameworks looks complicated, it isn't that bad... +# ...see Modifiers in zshexpn(1) for details. + +# List of ZSH versions +typeset -a versions +versions=( docker/base-*/Dockerfile(N.on:h:t:s/base-//) ) + +# List of frameworks +typeset -a frameworks +frameworks=( docker/*/Dockerfile(N.on:h:t) ) +frameworks=${(@)frameworks:#base-*} + +err() { - for path in docker/*/Dockerfile(N.); do - framework=${path:h:t} - if [[ "$framework" == base ]]; then continue; fi - echo "$framework" - done + print -P "%F{red}Error:%f $*" + exit 2 } -show-help() -{ - echo "Usage: ${(%):-%x} |--list" - echo - echo "Loads up a docker image with powershell9k configured in " - echo - echo " --list Lists all available framework containers." - echo - echo "Framework containers:" - for f in $(frameworks); do - echo " - $f" - done +resolve_framework() { + local f=$1 found + found=${frameworks[(In:-1:)$f*]} + if (( found <= $#frameworks )); then + echo "${frameworks[$found]}" + fi } -build-and-run() -{ - local framework="$1" ; shift +resolve_version() { + local v=$1 found + found=${versions[(In:-1:)$v*]} + if (( found <= $#versions )); then + echo "${versions[$found]}" + fi +} - print -P "%F{green}Preparing ${framework} container...%f" +build_and_run() { + local version="$1" + local framework="$2" + local name="${version}-${framework}" - if [[ "$framework" != "base" ]]; then - echo -n "p9k:base: " - docker build \ - --quiet \ - --tag p9k:base \ - --file docker/base/Dockerfile \ - . - fi - echo -n "p9k:${framework}: " + print -P "%F{green}Preparing containers...%f" + + echo -n "p9k:base-${version}: " docker build \ --quiet \ - --tag "p9k:${framework}" \ - --file "docker/${framework}/Dockerfile" \ + --tag "p9k:base-${version}" \ + --file "docker/base-${version}/Dockerfile" \ . + echo -n "p9k:${version}-${framework}: " + docker build \ + --quiet \ + --build-arg="base=base-${version}" \ + --tag "p9k:${version}-${framework}" \ + --file "docker/${framework}/Dockerfile" \ + . - print -P "%F{green}Starting ${framework} container...%f" + print -P "%F{green}Starting ${name} container...%f" exec docker run \ --rm \ --interactive \ --tty \ - --hostname="${framework}" \ + --hostname="${name//./_}" \ --env="TERM=${term}" \ - "$@" \ - "p9k:${framework}" + "p9k:${version}-${framework}" +} + +show_help() { + local f v + echo "Usage: ${(%):-%x} |--list" + echo + echo "Loads up a docker image with powershell9k configured in " + echo + echo " --frameworks Lists all available frameworks, newline separated." + echo " --versions Lists all available ZSH versions, newline separated." + echo " --zsh VER Uses ZSH with version VER." + echo " --help You're soaking in it." + echo + echo "ZSH versions:" + for v in "${(@)versions}"; do + echo " $v" + done + echo + echo "Framework containers:" + for f in "${(@)frameworks}"; do + echo " $f" + done } -arg1="${1:-}"; if (( $# > 0 )); then shift; fi - -if [[ -z "$arg1" ]] || [[ "$arg1" == "help" ]]; then - show-help - exit 0 -elif [[ "$arg1" == '--list' ]]; then - frameworks - exit 0 -elif [[ -d "docker/${arg1}" ]]; then - build-and-run "$arg1" -elif [[ -n "docker/${arg1}"*/Dockerfile(#qN) ]]; then - # Allow globbing - build-and-run "docker/${arg1}"*(Y1:t) -else - show-help - exit 1 +# No arguments +if (( $# == 0 )); then + show_help + exit fi +# Parse flags and such. +use_version=$default_version +use_framework= +while (( $# > 0 )); do + case "$1" in + -f | --frameworks ) + print -l "${(@)frameworks}" + exit + ;; + -v | --versions ) + print -l "${(@)versions}" + exit + ;; + -z | --zsh ) + shift + local v="$(resolve_version "$1")" + if [[ -n "$v" ]]; then + use_version=$v + else + err "No such ZSH version '${1}'" + fi + ;; + -h | --help ) + show_help + exit + ;;; + -* ) + err "Unknown option ${1}" + show_help + exit 1 + ;; + * ) + if [[ -z "$use_framework" ]]; then + local f="$(resolve_framework "$1")" + if [[ -n "$f" ]]; then + use_framework=$f + else + err "No such framework '${1}'" + fi + else + err "You can only specify one framework at a time; you already specified '${use_framework}'" + fi + ;; + esac + shift +done + +build_and_run "$use_version" "$use_framework" + # EOF From 82f319d1fbe25fe450d0851a5556545a11d9502d Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Wed, 12 Jul 2017 10:33:26 -0400 Subject: [PATCH 41/99] Adding Code of Conduct Slightly modified version of Contributors Covenant. --- CODE_OF_CONDUCT.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..22c9ebb4 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at bhilburn@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From ecc6356e9de6c89eeb44f145c3b831f25ad5796f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Thu, 13 Jul 2017 00:39:58 -0400 Subject: [PATCH 42/99] test-in-docker: show known issues --- test-in-docker | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test-in-docker b/test-in-docker index c1aafcd9..3c7255ec 100755 --- a/test-in-docker +++ b/test-in-docker @@ -23,6 +23,14 @@ typeset -a frameworks frameworks=( docker/*/Dockerfile(N.on:h:t) ) frameworks=${(@)frameworks:#base-*} +# Known Issues +typeset -A known_issues +known_issues["4.3.11-antigen"]="Antigen commands that need git won't work; it needs a newer version of git." +known_issues["4.3.11-zim"]="BROKEN: Zim wants ZSH 5.2 or newer." +known_issues["5.0.3-zim"]="DEPRECATED: Zim wants ZSH 5.2 or newer." +known_issues["5.1.1-zim"]="DEPRECATED: Zim wants ZSH 5.2 or newer." +known_issues["4.3.11-zulu"]="Zulu doesn't work; it needs a newer version of git." + err() { print -P "%F{red}Error:%f $*" @@ -45,11 +53,25 @@ resolve_version() { fi } +check_for_known_issues() { + local version="$1" + local framework="$2" + local name="${version}-${framework}" + + if (( ${+known_issues["$name"]} )); then + echo + print -P "%F{red}Known Issue: %F{yellow}${known_issues["$name"]}%f" + echo + fi +} + build_and_run() { local version="$1" local framework="$2" local name="${version}-${framework}" + check_for_known_issues "$version" "$framework" + print -P "%F{green}Preparing containers...%f" echo -n "p9k:base-${version}: " From a4f1ce990b219b4ce66018aa59a72b3c24b69dd9 Mon Sep 17 00:00:00 2001 From: AdrienHorgnies Date: Sat, 15 Jul 2017 21:28:27 +0200 Subject: [PATCH 43/99] change status segment option set --- powerlevel9k.zsh-theme | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b08155ed..73682f38 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1087,9 +1087,13 @@ prompt_ssh() { fi } -# Status: return code if verbose, otherwise just an icon if an error occurred +# old options, retro compatibility set_default POWERLEVEL9K_STATUS_VERBOSE true set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false +# Status: When an error occur, return the error code, or a cross icon if option is set +# Display an ok icon when no error occur, or hide the segment if option is set to false +set_default POWERLEVEL9K_STATUS_CROSS false +set_default POWERLEVEL9K_STATUS_OK true set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true prompt_status() { local ec_text @@ -1112,12 +1116,12 @@ prompt_status() { fi if (( ec_sum > 0 )); then - if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then + if [[ "$POWERLEVEL9K_STATUS_CROSS" == false && "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then "$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$ec_text" 'CARRIAGE_RETURN_ICON' else "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' fi - elif [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then + elif [[ "$POWERLEVEL9K_STATUS_OK" == true ]] && [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON' fi } From faa5ec96453ccd6b91ab91d56c68dc5a3ddf554a Mon Sep 17 00:00:00 2001 From: AdrienHorgnies Date: Sat, 15 Jul 2017 20:33:07 +0200 Subject: [PATCH 44/99] document status segment new option set --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f885f877..dce219ac 100644 --- a/README.md +++ b/README.md @@ -505,8 +505,8 @@ This segment shows the return code of the last command. | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_STATUS_VERBOSE`|`true`|Set to false if you wish to not show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE` to false.| -|`POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE`|`false`|Set to true if you wish to show this segment when the last command completed successfully in non-verbose mode.| +|`POWERLEVEL9K_STATUS_CROSS`|`false`|Set to true if you wish not to show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK` to false.| +|`POWERLEVEL9K_STATUS_OK`|`true`|Set to true if you wish to show this segment when the last command completed successfully, false to hide it.| |`POWERLEVEL9K_STATUS_SHOW_PIPESTATUS`|`true`|Set to true if you wish to show the exit status for all piped commands.| ##### ram From e3530de3dc2afc56836f3f2113734e3b42b15f1b Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 22 Jul 2017 12:51:39 -0300 Subject: [PATCH 45/99] Fix reference for python icon. While using awesome-terminal-fonts it is recommended to use `\ue63c` to reference python icon instead of `\U1F40D` (that wasn't even working). Ref: https://github.com/gabrielelana/awesome-terminal-fonts/issues/38#issuecomment-302939451 --- functions/icons.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 5e719be1..272de840 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -76,7 +76,7 @@ case $POWERLEVEL9K_MODE in VCS_HG_ICON $'\uE1C3 ' #  VCS_SVN_ICON '(svn) ' RUST_ICON '' - PYTHON_ICON $'\U1F40D' # 🐍 + PYTHON_ICON $'\ue63c' #  SWIFT_ICON '' GO_ICON '' PUBLIC_IP_ICON '' @@ -143,7 +143,7 @@ case $POWERLEVEL9K_MODE in VCS_HG_ICON $'\uF0C3 ' #  VCS_SVN_ICON '(svn) ' RUST_ICON $'\uE6A8' #  - PYTHON_ICON $'\U1F40D' # 🐍 + PYTHON_ICON $'\ue63c' #  SWIFT_ICON '' GO_ICON '' PUBLIC_IP_ICON '' From be6c0320252d2c750884a90664a26b58eb824920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Wed, 26 Jul 2017 23:39:49 -0400 Subject: [PATCH 46/99] rvm: handle -head, etc. more gracefully. Closes #575 --- powerlevel9k.zsh-theme | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 16904af7..d6ce38f1 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1070,13 +1070,10 @@ prompt_rspec_stats() { # Ruby Version Manager information prompt_rvm() { - local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') - [ "$gemset" != "" ] && gemset="@$gemset" + local version_and_gemset=${rvm_env_string/ruby-} - local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $NF}') - - if [[ -n "$version$gemset" ]]; then - "$1_prompt_segment" "$0" "$2" "240" "$DEFAULT_COLOR" "$version$gemset" 'RUBY_ICON' + if [[ -n "$version_and_gemset" ]]; then + "$1_prompt_segment" "$0" "$2" "240" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' fi } From 1ded7c2c902536eb9582cad08b4b69b15d8761a5 Mon Sep 17 00:00:00 2001 From: Giorgi Gzirishvili Date: Fri, 28 Jul 2017 02:50:31 +0400 Subject: [PATCH 47/99] Update OK_ICON weight to march FAIL_ICON Fixes #576. --- functions/icons.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 272de840..ab4d2bac 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -35,7 +35,7 @@ case $POWERLEVEL9K_MODE in TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\uE894' #  DISK_ICON $'\uE1AE ' #  - OK_ICON $'\u2713' # ✓ + OK_ICON $'\u2714' # ✔ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ @@ -106,7 +106,7 @@ case $POWERLEVEL9K_MODE in TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 DISK_ICON $'\uF0A0 ' #  - OK_ICON $'\u2713' # ✓ + OK_ICON $'\u2714' # ✔ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ @@ -240,7 +240,7 @@ case $POWERLEVEL9K_MODE in TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 DISK_ICON $'hdd ' - OK_ICON $'\u2713' # ✓ + OK_ICON $'\u2714' # ✔ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ From f93ad073b792a2bda81a4ffb0584aa398866f81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Wed, 26 Jul 2017 22:21:18 -0400 Subject: [PATCH 48/99] status: show signal name This makes signal exit status easy to understand. Instead of just showing exit code "137", you now see "KILL(-9)". Based on #580 by @sei40kr (thanks!) --- README.md | 1 + powerlevel9k.zsh-theme | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dce219ac..dd79cd65 100644 --- a/README.md +++ b/README.md @@ -508,6 +508,7 @@ This segment shows the return code of the last command. |`POWERLEVEL9K_STATUS_CROSS`|`false`|Set to true if you wish not to show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK` to false.| |`POWERLEVEL9K_STATUS_OK`|`true`|Set to true if you wish to show this segment when the last command completed successfully, false to hide it.| |`POWERLEVEL9K_STATUS_SHOW_PIPESTATUS`|`true`|Set to true if you wish to show the exit status for all piped commands.| +|`POWERLEVEL9K_STATUS_HIDE_SIGNAME`|`false`|Set to true return the raw exit code (`1-255`). When set to true, values over 128 are shown as `SIGNAME(-n)` (e.g. `KILL(-9)`)| ##### ram diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 16904af7..20c59c01 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1086,31 +1086,47 @@ prompt_ssh() { fi } -# old options, retro compatibility -set_default POWERLEVEL9K_STATUS_VERBOSE true -set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false # Status: When an error occur, return the error code, or a cross icon if option is set # Display an ok icon when no error occur, or hide the segment if option is set to false +# set_default POWERLEVEL9K_STATUS_CROSS false set_default POWERLEVEL9K_STATUS_OK true set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true +set_default POWERLEVEL9K_STATUS_HIDE_SIGNAME false +# old options, retro compatibility +set_default POWERLEVEL9K_STATUS_VERBOSE true +set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false + +exit_code_or_status() { + local ec=$1 + if [[ "$POWERLEVEL9K_STATUS_HIDE_SIGNAME" = true ]]; then + echo "$ec" + elif (( ec <= 128 )); then + echo "$ec" + else + local sig=$(( ec - 128 )) + local idx=$(( sig + 1 )) + echo "${signals[$idx]}(-${sig})" + fi +} + prompt_status() { local ec_text local ec_sum local ec if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then - ec_text=${RETVALS[1]} + ec_text=$(exit_code_or_status "${RETVALS[1]}") ec_sum=${RETVALS[1]} for ec in "${(@)RETVALS[2,-1]}"; do - ec_text="${ec_text}|${ec}" + ec_text="${ec_text}|$(exit_code_or_status "$ec")" ec_sum=$(( $ec_sum + $ec )) done else # We use RETVAL instead of the right-most RETVALS item because # PIPE_FAIL may be set. - ec_text=${RETVAL} + ec_text=$(exit_code_or_status "${RETVAL}") ec_sum=${RETVAL} fi From 0b298e7df423882ba797b80a4e4b5a9a0546b666 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Tue, 27 Jun 2017 19:32:24 +0900 Subject: [PATCH 49/99] Fixed an issue of indicator of Vi mode Fixed an issue that the indicator of Vi mode won't appear correctly at first. --- powerlevel9k.zsh-theme | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 26ab9cd5..015fa41e 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1192,12 +1192,12 @@ set_default POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT" set_default POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL" prompt_vi_mode() { case ${KEYMAP} in - main|viins) - "$1_prompt_segment" "$0_INSERT" "$2" "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_MODE_STRING" - ;; vicmd) "$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" ;; + main|viins|*) + "$1_prompt_segment" "$0_INSERT" "$2" "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_MODE_STRING" + ;; esac } From 41b469ed9b803a617b103bd65c842138f359ad82 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Thu, 3 Aug 2017 15:52:28 -0400 Subject: [PATCH 50/99] Quick fix to next exit code doc in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd79cd65..f06d8e07 100644 --- a/README.md +++ b/README.md @@ -508,7 +508,7 @@ This segment shows the return code of the last command. |`POWERLEVEL9K_STATUS_CROSS`|`false`|Set to true if you wish not to show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK` to false.| |`POWERLEVEL9K_STATUS_OK`|`true`|Set to true if you wish to show this segment when the last command completed successfully, false to hide it.| |`POWERLEVEL9K_STATUS_SHOW_PIPESTATUS`|`true`|Set to true if you wish to show the exit status for all piped commands.| -|`POWERLEVEL9K_STATUS_HIDE_SIGNAME`|`false`|Set to true return the raw exit code (`1-255`). When set to true, values over 128 are shown as `SIGNAME(-n)` (e.g. `KILL(-9)`)| +|`POWERLEVEL9K_STATUS_HIDE_SIGNAME`|`false`|Set to true return the raw exit code (`1-255`). When set to false, values over 128 are shown as `SIGNAME(-n)` (e.g. `KILL(-9)`)| ##### ram From b567ab22c2889726974dcfed543cc9ecb7e190cb Mon Sep 17 00:00:00 2001 From: Richard Tippl Date: Tue, 8 Aug 2017 19:44:20 +0200 Subject: [PATCH 51/99] Implemented functionality from dir_writable to dir When variable POWERLEVEL9K_DIR_SHOW_WRITABLE is set to true, dir prompt will have new state NOT_WRITABLE. This state will be set when user doesn't have permission to write in current working directory as in prompt dir_writable. When mode that allows icons is set, LOCK_ICON is used. --- powerlevel9k.zsh-theme | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c2b53374..807495ec 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -802,9 +802,12 @@ prompt_dir() { "DEFAULT" "FOLDER_ICON" "HOME" "HOME_ICON" "HOME_SUBFOLDER" "HOME_SUB_ICON" + "NOT_WRITABLE" "LOCK_ICON" ) local current_state="DEFAULT" - if [[ $(print -P "%~") == '~' ]]; then + if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == "true" && ! -w "$PWD" ]]; then + current_state="NOT_WRITABLE" + elif [[ $(print -P "%~") == '~' ]]; then current_state="HOME" elif [[ $(print -P "%~") == '~'* ]]; then current_state="HOME_SUBFOLDER" From c4a1d91118abe95f4f5ce0580ffe58b452affefa Mon Sep 17 00:00:00 2001 From: Richard Tippl Date: Thu, 10 Aug 2017 17:49:42 +0200 Subject: [PATCH 52/99] Added a default value for DIR_SHOW_WRITABLE. Variable POWERLEVEL9K_DIR_SHOW_WRITABLE is now default set to false. --- powerlevel9k.zsh-theme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 807495ec..8c78cb00 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -689,6 +689,7 @@ prompt_command_execution_time() { # Dir: current working directory set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" +set_default POWERLEVEL9K_DIR_SHOW_WRITABLE false prompt_dir() { local current_path="$(print -P "%~")" if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then @@ -805,7 +806,7 @@ prompt_dir() { "NOT_WRITABLE" "LOCK_ICON" ) local current_state="DEFAULT" - if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == "true" && ! -w "$PWD" ]]; then + if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then current_state="NOT_WRITABLE" elif [[ $(print -P "%~") == '~' ]]; then current_state="HOME" From cefe984e3d1a932a4351b211183f3ae1a60e4842 Mon Sep 17 00:00:00 2001 From: Richard Tippl Date: Thu, 10 Aug 2017 19:08:33 +0200 Subject: [PATCH 53/99] Documented DIR_SHOW_WRITABLE in README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f06d8e07..ed46fc7f 100644 --- a/README.md +++ b/README.md @@ -402,6 +402,8 @@ You can also customize the leading tilde character when you are in `$HOME` using # Double quotes are important here! POWERLEVEL9K_HOME_FOLDER_ABBREVIATION="%F{red} $(print_icon 'HOME_ICON') %F{black}" ``` +If you want to see, when you do not have write permissions on the current folder, you can set `POWERLEVEL9K_DIR_SHOW_WRITABLE=true`. +This will set the `dir` segment to a `NOT_WRITABLE` state when current folder is not writable, allowing you to customize the `dir` segment [colors](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization). ##### disk_usage From 99b7ec26b24418329d0ab81f0c649037cc399254 Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Thu, 10 Aug 2017 11:56:12 -0700 Subject: [PATCH 54/99] Add back the prompt_sp option for zsh >= 5.4.1 In 5.4.1, this option was reset between prompts, so to retain the previous default behavior, this should be added back. --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 5bd5f586..b21e2ff4 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1341,11 +1341,11 @@ prompt_powerlevel9k_setup() { # returns. We need prompt_subst so we can safely run commands in the prompt # without them being double expanded and we need prompt_percent to expand the # common percent escape sequences. - prompt_opts=(subst percent cr) + prompt_opts=(cr percent sp subst) # Borrowed from promptinit, sets the prompt options in case the theme was # not initialized via promptinit. - setopt noprompt{bang,cr,percent,subst} "prompt${^prompt_opts[@]}" + setopt noprompt{bang,cr,percent,sp,subst} "prompt${^prompt_opts[@]}" # Display a warning if the terminal does not support 256 colors local term_colors From 73a9ee7c870fcc93182c17f7d9d0c6942116169d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= <6774676+eumiro@users.noreply.github.com> Date: Fri, 11 Aug 2017 22:44:18 +0200 Subject: [PATCH 55/99] add TRUNCATE_TO_UNIQUE shortening dir strategy This creates the shortest unique path elements that can be unambiguously expanded to the original path. --- README.md | 1 + powerlevel9k.zsh-theme | 21 +++++++++++++++++++++ test/segments/dir.spec | 21 +++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/README.md b/README.md index 1f7dcadb..e428e6d8 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,7 @@ Customizations available are: |`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).| +|`truncate_to_unique`|Parse all parent path components and truncate them to the shortest unique length. If you copy&paste the result to a shell, after hitting TAB it should expand to the original path unambiguously.| For example, if you wanted the truncation behavior of the `fish` shell, which truncates `/usr/share/plasma` to `/u/s/plasma`, you would use the following: diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 5bd5f586..3869d262 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -709,6 +709,27 @@ prompt_dir() { # the current path. current_path=$current_path${PWD#${last_marked_folder}*} ;; + truncate_to_unique) + # for each parent path component find the shortest unique beginning + # characters sequence + paths=(${(s:/:)PWD}) + cur_path='/' + cur_short_path='/' + for directory in ${paths[@]} + do + cur_dir='' + for (( i=0; i<${#directory}; i++ )); do + cur_dir+="${directory:$i:1}" + matching=("$cur_path"/"$cur_dir"*/) + if [[ ${#matching[@]} -eq 1 ]]; then + break + fi + done + cur_short_path+="$cur_dir/" + cur_path+="$directory/" + done + current_path="${cur_short_path: : -1}" + ;; *) current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" ;; diff --git a/test/segments/dir.spec b/test/segments/dir.spec index 3a6af649..dea54750 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -381,4 +381,25 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncat unset POWERLEVEL9K_SHORTEN_STRATEGY } +function testTruncateToUniqueWorks() { + POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true + POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_STRATEGY='truncate_to_unique' + mkdir -p /tmp/powerlevel9k-test/adam/devl + mkdir -p /tmp/powerlevel9k-test/alice/devl + mkdir -p /tmp/powerlevel9k-test/alice/docs + mkdir -p /tmp/powerlevel9k-test/bob/docs + cd /tmp/powerlevel9k-test/alice/devl + + assertEquals "%K{blue} %F{black}txXxpxXxalxXxde %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_SEPARATOR + unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER + unset POWERLEVEL9K_SHORTEN_DIR_LENGTH + unset POWERLEVEL9K_SHORTEN_STRATEGY +} + source shunit2/source/2.1/src/shunit2 From d784b1c8dce142fbf3f032c771252c2ffb563cec Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 12 Aug 2017 13:15:29 -0400 Subject: [PATCH 56/99] Cleaning up the `dir` docs in README --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ed46fc7f..225f14e7 100644 --- a/README.md +++ b/README.md @@ -402,9 +402,11 @@ You can also customize the leading tilde character when you are in `$HOME` using # Double quotes are important here! POWERLEVEL9K_HOME_FOLDER_ABBREVIATION="%F{red} $(print_icon 'HOME_ICON') %F{black}" ``` -If you want to see, when you do not have write permissions on the current folder, you can set `POWERLEVEL9K_DIR_SHOW_WRITABLE=true`. -This will set the `dir` segment to a `NOT_WRITABLE` state when current folder is not writable, allowing you to customize the `dir` segment [colors](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization). +You can also configure the `dir` segment to show when you are in a directory without write permissions, using the variable below. +| 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`.| ##### disk_usage From 5923aaf07d75a2e3f0ca0781240314e0ab91a431 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 12 Aug 2017 13:49:14 -0400 Subject: [PATCH 57/99] README: Slight change to new truncation strategy doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e428e6d8..bb07b7fd 100644 --- a/README.md +++ b/README.md @@ -313,7 +313,7 @@ Customizations available are: |`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).| -|`truncate_to_unique`|Parse all parent path components and truncate them to the shortest unique length. If you copy&paste the result to a shell, after hitting TAB it should expand to the original path unambiguously.| +|`truncate_to_unique`|Parse all parent path components and truncate them to the shortest unique length. If you copy & paste the result to a shell, after hitting `TAB` it should expand to the original path unambiguously.| For example, if you wanted the truncation behavior of the `fish` shell, which truncates `/usr/share/plasma` to `/u/s/plasma`, you would use the following: From e464b4e2a559508f9f4e0a9bc28a3b1e7d08fbd6 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 12 Aug 2017 13:49:50 -0400 Subject: [PATCH 58/99] Adding reference for `truncate_to_unique` code. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 3869d262..3baa50ce 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -711,7 +711,7 @@ prompt_dir() { ;; truncate_to_unique) # for each parent path component find the shortest unique beginning - # characters sequence + # characters sequence. Source: https://stackoverflow.com/a/45336078 paths=(${(s:/:)PWD}) cur_path='/' cur_short_path='/' From a62fffa2b17da7ee43afec5776c50603921e2b5c Mon Sep 17 00:00:00 2001 From: Varun Dey Date: Mon, 14 Aug 2017 16:08:50 +0530 Subject: [PATCH 59/99] Updated braces for hyperlink --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f7dcadb..6b47b7e3 100644 --- a/README.md +++ b/README.md @@ -267,7 +267,7 @@ POWERLEVEL9K_CONTEXT_TEMPLATE="%n@`hostname -f`" You can set the `POWERLEVEL9K_CONTEXT_HOST_DEPTH` variable to change how the -hostname is displayed. See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information] +hostname is displayed. See [ZSH Manual](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information) for details. The default is set to %m which will show the hostname up to the first ‘.’ You can set it to %{N}m where N is an integer to show that many segments of system hostname. Setting N to a negative integer will show that many segments from the From 582edf200c825abbc75ec8a643b2e7ecdbd59561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadek=20Tele=C5=BCy=C5=84ski?= Date: Thu, 17 Aug 2017 21:54:26 +0200 Subject: [PATCH 60/99] Add average choice to load extension This commit adds a functionality to choose if one wants to see 1, 5 or 15 minutes average. Resolves issue #604 --- README.md | 13 ++++++++++++- powerlevel9k.zsh-theme | 23 +++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9c17c2c5..9c0c3ab5 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ The segments that are currently available are: * [`ip`](#ip) - Shows the current IP address. * [`vpn`](#vpn) - Shows the current VPN IP address. * [`public_ip`](#public_ip) - Shows your public IP address. -* `load` - Your machine's load averages. +* [`load`](#load) - Your machine's load averages. * `os_icon` - Display a nice little icon, depending on your operating system. * `ram` - Show free RAM. * `root_indicator` - An indicator if the user has superuser status. @@ -482,6 +482,17 @@ segment will not be displayed. |`POWERLEVEL9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.| |`POWERLEVEL9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained| +##### load + +Displays one of your load averages with appropriate state coloring. The thresholds are: +- `0.7 * NUM_CORES <`: critical +- `0.5 * NUM_CORES <`: warning +- `less`: normal + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_LOAD_WHICH`|5|Which average to show. Possible values: 1, 5 or 15| + ##### newline Puts a newline in your prompt so you can continue using segments on the next diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 3c34f0bb..b03a9374 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -937,6 +937,8 @@ prompt_load() { local current_state="unknown" local cores + set_default POWERLEVEL9K_LOAD_WHICH 5 + typeset -AH load_states load_states=( 'critical' 'red' @@ -945,31 +947,40 @@ prompt_load() { ) if [[ "$OS" == "OSX" ]] || [[ "$OS" == "BSD" ]]; then - load_avg_1min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1) + + 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 + if [[ "$OS" == "OSX" ]]; then cores=$(sysctl -n hw.logicalcpu) else cores=$(sysctl -n hw.ncpu) fi else - load_avg_1min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1) + load_avg=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1) cores=$(nproc) fi # Replace comma - load_avg_1min=${load_avg_1min//,/.} + load_avg=${load_avg//,/.} - if [[ "$load_avg_1min" -gt $(bc -l <<< "${cores} * 0.7") ]]; then + if [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.7") ]]; then current_state="critical" - elif [[ "$load_avg_1min" -gt $(bc -l <<< "${cores} * 0.5") ]]; then +elif [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.5") ]]; then current_state="warning" else current_state="normal" fi - "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg_1min" 'LOAD_ICON' + "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON' } + # Node version prompt_node_version() { local node_version=$(node -v 2>/dev/null) From 348178fd8d6f0c3005b13641eca09a0231122f55 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 26 Aug 2017 13:43:00 -0400 Subject: [PATCH 61/99] Updating CHANGELOG for v0.6.4 --- CHANGELOG.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42120aea..0a8842a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,24 @@ -## Next +## v0.6.4 +- `load` segment now has configurable averages. +- Update to `dir` segment to add `dir_writable` feature. +- `status` segment can now display POSIX signal name of exit code. - Added `teardown` command to turn off P9k prompt. - Fixes for P9k in Cygwin and 32-bit systems. - Better colors in virtualization segments. - Added 'Gopher' icon to the `go_version` segment. - Improved detection in `nvm` - Added option to support command status reading from piped command sequences. +- Fixed issue with visual artifacts with quick consecutive commands. +- Updated 'ananconda' segment for more uniform styling. +- `rvm` segment can now support usernames with dashes. +- Fixed Python icon reference in some font configurations. +- Vi mode indicator fixed. +- Fixes for Docker segment. +- Added new Docker-based testing system. +- Significant enhancements to the `battery` segment. Check out the README to + read more! +- New truncation strategy that truncates until the path becomes unique. ### New Segments: `host` and `user` @@ -24,11 +37,6 @@ Shows the current context of your `kubectl` configuration. Shows current `vpn` interface. -## v0.6.4 - -- Significant enhancements to the `battery` segment. Check out the README to - read more! - ## v0.6.3 - Fixed susceptibility to [pw3nage exploit](https://github.com/njhartwell/pw3nage). From 17c069d25ac7b24af6b5dc7ecb9597cef881f582 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 26 Aug 2017 13:59:15 -0400 Subject: [PATCH 62/99] 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 63/99] 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 64/99] 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 65/99] 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 66/99] 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." From f996d2d6ed3aa82f697f8b96afd57eb3b0593875 Mon Sep 17 00:00:00 2001 From: Hal Gentz Date: Thu, 28 Sep 2017 22:07:37 -0600 Subject: [PATCH 67/99] Fixes issue #619 Signed-off-by: Hal Gentz --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 7e7b4e11..e3ebf59f 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -570,7 +570,7 @@ prompt_context() { local content="" - if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then if [[ $(print -P "%#") == '#' ]]; then current_state="ROOT" From ec47f1b583d5e40e299f9b4b065fe1626240e5e5 Mon Sep 17 00:00:00 2001 From: Hal Gentz Date: Thu, 28 Sep 2017 22:20:58 -0600 Subject: [PATCH 68/99] These probably have similar bugs Signed-off-by: Hal Gentz --- powerlevel9k.zsh-theme | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index e3ebf59f..97d13a3c 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -579,7 +579,7 @@ prompt_context() { content="${POWERLEVEL9K_CONTEXT_TEMPLATE}" elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then - content="$USER" + content="$(whoami)" else return fi @@ -594,7 +594,7 @@ set_default POWERLEVEL9K_USER_TEMPLATE "%n" prompt_user() { local current_state="DEFAULT" typeset -AH user_state - if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]]; then + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]]; then if [[ $(print -P "%#") == '#' ]]; then user_state=( "STATE" "ROOT" @@ -606,7 +606,7 @@ prompt_user() { else user_state=( "STATE" "DEFAULT" - "CONTENT" "$USER" + "CONTENT" "$(whoami)" "BACKGROUND_COLOR" "${DEFAULT_COLOR}" "FOREGROUND_COLOR" "011" "VISUAL_IDENTIFIER" "USER_ICON" From 36b833aae391000ec752188fae4cc67a314a7756 Mon Sep 17 00:00:00 2001 From: Simon Pettersson Date: Thu, 5 Oct 2017 21:57:08 +0200 Subject: [PATCH 69/99] Corrected awesome-fontconfig lock icon --- functions/icons.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 3a4909f7..89fc0cd5 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -153,7 +153,7 @@ case $POWERLEVEL9K_MODE in SWIFT_ICON '' GO_ICON '' PUBLIC_IP_ICON '' - LOCK_ICON $'\UE138' #  + LOCK_ICON $'\UF023' #  EXECUTION_TIME_ICON $'\uF253' SSH_ICON '(ssh)' VPN_ICON $'\uF023' From 01b554cda8dab4d8854d93f41420a050917a3753 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 6 Oct 2017 21:43:25 -0400 Subject: [PATCH 70/99] Adding a space after VCS_BRANCH_ICON by default --- functions/icons.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 89fc0cd5..7124386b 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -69,7 +69,7 @@ case $POWERLEVEL9K_MODE in VCS_TAG_ICON $'\uE817 ' #  VCS_BOOKMARK_ICON $'\uE87B' #  VCS_COMMIT_ICON $'\uE821 ' #  - VCS_BRANCH_ICON $'\uE220' #  + VCS_BRANCH_ICON $'\uE220 ' #  VCS_REMOTE_BRANCH_ICON $'\u2192' # → VCS_GIT_ICON $'\uE20E ' #  VCS_GIT_GITHUB_ICON $'\uE20E ' # @@ -140,7 +140,7 @@ case $POWERLEVEL9K_MODE in VCS_TAG_ICON $'\uF217 ' #  VCS_BOOKMARK_ICON $'\uF27B' #  VCS_COMMIT_ICON $'\uF221 ' #  - VCS_BRANCH_ICON $'\uF126' #  + VCS_BRANCH_ICON $'\uF126 ' #  VCS_REMOTE_BRANCH_ICON $'\u2192' # → VCS_GIT_ICON $'\uF1D3 ' #  VCS_GIT_GITHUB_ICON $'\uF113 ' #  @@ -282,7 +282,7 @@ case $POWERLEVEL9K_MODE in VCS_TAG_ICON '' VCS_BOOKMARK_ICON $'\u263F' # ☿ VCS_COMMIT_ICON '' - VCS_BRANCH_ICON $'\uE0A0' #  + VCS_BRANCH_ICON $'\uE0A0 ' #  VCS_REMOTE_BRANCH_ICON $'\u2192' # → VCS_GIT_ICON '' VCS_GIT_GITHUB_ICON '' From 834b6735fa8867b5447f79f94915835cb871a08a Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 6 Oct 2017 22:41:57 -0400 Subject: [PATCH 71/99] Fixing `vcs.spec` tests after adding space. --- test/segments/vcs.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec index 4467145e..c33b564d 100755 --- a/test/segments/vcs.spec +++ b/test/segments/vcs.spec @@ -21,7 +21,7 @@ function testColorOverridingForCleanStateWorks() { cd $FOLDER git init 1>/dev/null - assertEquals "%K{white} %F{cyan}master %k%F{white}%f " "$(build_left_prompt)" + assertEquals "%K{white} %F{cyan} master %k%F{white}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test @@ -47,7 +47,7 @@ function testColorOverridingForModifiedStateWorks() { git commit -m "test" 1>/dev/null echo "test" > testfile - assertEquals "%K{yellow} %F{red}master ● %k%F{yellow}%f " "$(build_left_prompt)" + assertEquals "%K{yellow} %F{red} master ● %k%F{yellow}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test @@ -68,7 +68,7 @@ function testColorOverridingForUntrackedStateWorks() { git init 1>/dev/null touch testfile - assertEquals "%K{yellow} %F{cyan}master ? %k%F{yellow}%f " "$(build_left_prompt)" + assertEquals "%K{yellow} %F{cyan} master ? %k%F{yellow}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test From 954faf2695e138570f41ba368c02b992e9d607ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=A9rence=20Clastres?= Date: Sat, 7 Oct 2017 19:16:06 +0200 Subject: [PATCH 72/99] Fix incomplete vpn segment name The segment function is called *prompt_vpn_ip()* thus the segment needs to be called "vpn_ip". --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d0ba2be..18c9acc3 100644 --- a/README.md +++ b/README.md @@ -451,7 +451,7 @@ specify the correct network interface by setting: |----------|---------------|-------------| |`POWERLEVEL9K_IP_INTERFACE`|None|The NIC for which you wish to display the IP address. Example: `eth0`.| -##### vpn +##### vpn_ip This segment tries to extract the VPN related IP addresses from nmcli, based on the NIC type: From 20b69370a679b6c3a8a2084615206d78fe0ae542 Mon Sep 17 00:00:00 2001 From: sbutler2901 Date: Thu, 12 Oct 2017 02:02:45 -0400 Subject: [PATCH 73/99] Bug fix for prompt_public_ip. The OSX date command does not have the -r option for getting the last modification time of a file. The stat command is being used instead --- powerlevel9k.zsh-theme | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 97d13a3c..f6646c63 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -507,7 +507,11 @@ prompt_public_ip() { if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then typeset -i timediff # if saved IP is more than - timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) + if [[ "$OS" == "OSX" ]]; then + timediff=$(($(date +%s) - $(stat -f "%m" $POWERLEVEL9K_PUBLIC_IP_FILE))) + else + timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) + fi [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMEOUT ]] && refresh_ip=true # If tmp file is empty get a fresh IP [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true From 8d653c9320151817129dd5d90e0b264d4963d667 Mon Sep 17 00:00:00 2001 From: Clay Anderson Date: Tue, 17 Oct 2017 14:45:07 -0600 Subject: [PATCH 74/99] Add *.swp to ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8f6423fa..8bebd352 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ test-vm/.vagrant +*.swp From b582a60adcf47c7967c3cb3cd43337b3a74e1f7c Mon Sep 17 00:00:00 2001 From: Clay Anderson Date: Tue, 17 Oct 2017 14:52:46 -0600 Subject: [PATCH 75/99] Add documentation for VCS hooks config --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 9d0ba2be..6178adad 100644 --- a/README.md +++ b/README.md @@ -582,6 +582,9 @@ customization is provided via: |`POWERLEVEL9K_CHANGESET_HASH_LENGTH`|`12`|How many characters of the hash / changeset to display in the segment.| |`POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY`|`true`|Set to `false` to not reflect submodule status in the top-level repository prompt.| |`POWERLEVEL9K_VCS_HIDE_TAGS`|`false`|Set to `true` to stop tags being displayed in the segment.| +|`POWERLEVEL9K_VCS_GIT_HOOKS`|`(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname)`|Layout of the segment for git repositories.| +|`POWERLEVEL9K_VCS_HG_HOOKS`|`(vcs-detect-changes)`|Layout of the segment for Mercurial repositories.| +|`POWERLEVEL9K_VCS_SVN_HOOKS`|`(vcs-detect-changes svn-detect-changes)`|Layout of the segment for SVN repositories.| ##### vcs symbols From 3b2a2bb0cd312608626c9d4ed85e017ea998de73 Mon Sep 17 00:00:00 2001 From: "George D. Plymale II" Date: Tue, 24 Oct 2017 02:00:11 -0400 Subject: [PATCH 76/99] remove weird glyphs in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e82b036..7c1974de 100644 --- a/README.md +++ b/README.md @@ -436,8 +436,8 @@ POWERLEVEL9K_HOST_TEMPLATE="%2m" By default, LOCAL hosts will show the host icon and remote hosts will show the SSH icon. You can override them by setting ``` -POWERLEVEL9K_HOST_ICON="\uF109 " #  -POWERLEVEL9K_SSH_ICON="\uF489 " #  +POWERLEVEL9K_HOST_ICON="\uF109 " +POWERLEVEL9K_SSH_ICON="\uF489 " ``` From 43e766209b0e6061bbf62c029098cd92a9408c1f Mon Sep 17 00:00:00 2001 From: Brian Moran Date: Fri, 27 Oct 2017 12:11:48 -0400 Subject: [PATCH 77/99] ISS-650 Fix PYTHONPATH appearing in prompt - Modify prompt_dir function to set current_path based on pwd and replace $HOME with ~ --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b03a9374..5ba9e43d 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -691,7 +691,7 @@ set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" set_default POWERLEVEL9K_DIR_SHOW_WRITABLE false prompt_dir() { - local current_path="$(print -P "%~")" + local current_path=$(pwd | sed -e "s,^$HOME,~,") if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\U2026' From 47c7077cde833217db8a4dadbabaf38e6ff490d3 Mon Sep 17 00:00:00 2001 From: Marc Hauptmann Date: Tue, 31 Oct 2017 16:47:21 +0100 Subject: [PATCH 78/99] declared variables as 'local' Prevents warning messages from zsh --- powerlevel9k.zsh-theme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f6646c63..3c173e9f 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1332,7 +1332,7 @@ powerlevel9k_vcs_init() { prompt_vcs() { VCS_WORKDIR_DIRTY=false VCS_WORKDIR_HALF_DIRTY=false - current_state="" + local current_state="" # Actually invoke vcs_info manually to gather all information. vcs_info @@ -1434,6 +1434,7 @@ prompt_kubecontext() { # Main prompt build_left_prompt() { local index=1 + local element for element in "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[@]}"; do # Remove joined information in direct calls element=${element%_joined} From 82bc300c625831ac7fc0e6067e1ea460e8fd0e59 Mon Sep 17 00:00:00 2001 From: Antons Kranga Date: Tue, 7 Nov 2017 11:30:23 +0200 Subject: [PATCH 79/99] Add support for both AWS_PROFILE and AWS_DEFAULT_PROFILE --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f33d5a9a..73178865 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -287,7 +287,7 @@ prompt_anaconda() { # AWS Profile prompt_aws() { - local aws_profile="$AWS_DEFAULT_PROFILE" + local aws_profile="${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}" if [[ -n "$aws_profile" ]]; then "$1_prompt_segment" "$0" "$2" red white "$aws_profile" 'AWS_ICON' From 37f24dcc5f2898321a463f6a131020a6ee195f2c Mon Sep 17 00:00:00 2001 From: David Jetelina Date: Tue, 14 Nov 2017 18:58:16 +0100 Subject: [PATCH 80/99] Kubernetes segment shorter if possible Fixes #675 --- powerlevel9k.zsh-theme | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 73178865..17f1eac0 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1423,7 +1423,18 @@ prompt_kubecontext() { if [[ -z "$k8s_namespace" ]]; then k8s_namespace="default" fi - "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_context/$k8s_namespace" "KUBERNETES_ICON" + + local k8s_final_text="" + + if [[ "$k8s_context" == "k8s_namespace" ]]; then + # No reason to print out the same identificator twice + k8s_final_text="k8s_context" + else + k8s_final_text="$k8s_context/$k8s_namespace" + fi + + + "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" fi } From b8afde5598d1defe7e300a273dac5efd4194876f Mon Sep 17 00:00:00 2001 From: David Jetelina Date: Tue, 14 Nov 2017 19:01:20 +0100 Subject: [PATCH 81/99] added forgotten $ --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 17f1eac0..27608382 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1428,7 +1428,7 @@ prompt_kubecontext() { if [[ "$k8s_context" == "k8s_namespace" ]]; then # No reason to print out the same identificator twice - k8s_final_text="k8s_context" + k8s_final_text="$k8s_context" else k8s_final_text="$k8s_context/$k8s_namespace" fi From bc8a83208f9b4aa8fcc29cc35a0eeec3ae67c5b9 Mon Sep 17 00:00:00 2001 From: dinhnv Date: Wed, 22 Nov 2017 11:30:24 +0700 Subject: [PATCH 82/99] pyenv promt segment uses $PYENV_VERSION environment variable" --- powerlevel9k.zsh-theme | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 73178865..b65c2077 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1379,18 +1379,10 @@ prompt_virtualenv() { } # pyenv: current active python version (with restrictions) -# More information on pyenv (Python version manager like rbenv and rvm): -# https://github.com/yyuu/pyenv -# the prompt parses output of pyenv version and only displays the first word +# https://github.com/pyenv/pyenv#choosing-the-python-version prompt_pyenv() { - local pyenv_version="$(pyenv version 2>/dev/null)" - pyenv_version="${pyenv_version%% *}" - # XXX: The following should return the same as above. - # This reads better for devs familiar with sed/awk/grep/cut utilities - # Using shell expansion/substitution may hamper future maintainability - #local pyenv_version="$(pyenv version 2>/dev/null | head -n1 | cut -d' ' -f1)" - if [[ -n "$pyenv_version" && "$pyenv_version" != "system" ]]; then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$pyenv_version" 'PYTHON_ICON' + if [[ -n "$PYENV_VERSION" ]]; then + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' fi } From f154e75667aff0801c3d978b44f5e4551d91e240 Mon Sep 17 00:00:00 2001 From: Kentaro Hayashi Date: Mon, 27 Nov 2017 15:15:44 +0900 Subject: [PATCH 83/99] Disable alias of grep If user defined alias of grep command with '-r' or '--recursive' option, it causes a slow response of command line. It is not unexpected behavior of vcs info. This commit explicitly disables alias of grep to suppress side effects. --- functions/vcs.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/vcs.zsh b/functions/vcs.zsh index c3e507b9..89f04143 100644 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -17,7 +17,7 @@ function +vi-git-untracked() { fi if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ - -n $(git status ${FLAGS} | grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then + -n $(git status ${FLAGS} | \grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" VCS_WORKDIR_HALF_DIRTY=true else @@ -137,15 +137,15 @@ function +vi-vcs-detect-changes() { function +vi-svn-detect-changes() { local svn_status="$(svn status)" - if [[ -n "$(echo "$svn_status" | grep \^\?)" ]]; then + if [[ -n "$(echo "$svn_status" | \grep \^\?)" ]]; then hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" VCS_WORKDIR_HALF_DIRTY=true fi - if [[ -n "$(echo "$svn_status" | grep \^\M)" ]]; then + if [[ -n "$(echo "$svn_status" | \grep \^\M)" ]]; then hook_com[unstaged]+=" $(print_icon 'VCS_UNSTAGED_ICON')" VCS_WORKDIR_DIRTY=true fi - if [[ -n "$(echo "$svn_status" | grep \^\A)" ]]; then + if [[ -n "$(echo "$svn_status" | \grep \^\A)" ]]; then hook_com[staged]+=" $(print_icon 'VCS_STAGED_ICON')" VCS_WORKDIR_DIRTY=true fi From 6e931f6047994ebb4a83924c298678d059e183d4 Mon Sep 17 00:00:00 2001 From: Torben Hartmann Date: Mon, 27 Nov 2017 21:38:03 +0100 Subject: [PATCH 84/99] Fixed Issue with whitespaces in path. --- powerlevel9k.zsh-theme | 3 +++ 1 file changed, 3 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 73178865..5dd394ea 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -695,7 +695,10 @@ set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" set_default POWERLEVEL9K_DIR_SHOW_WRITABLE false prompt_dir() { + local tmp=$IFS + local IFS="" local current_path=$(pwd | sed -e "s,^$HOME,~,") + local IFS=$tmp if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\U2026' From 42b72423467b5457d1feb0b307712dc7badf80e5 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Mon, 4 Dec 2017 19:30:38 -0500 Subject: [PATCH 85/99] Updating build status to be `master` only. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c1974de..3ae786b8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![](https://raw.githubusercontent.com/bhilburn/powerlevel9k-logo/master/logo-banner.png) --- -[![Build Status](https://travis-ci.org/bhilburn/powerlevel9k.svg?branch=next)](https://travis-ci.org/bhilburn/powerlevel9k) +[![Build Status](https://travis-ci.org/bhilburn/powerlevel9k.svg?branch=master)](https://travis-ci.org/bhilburn/powerlevel9k) [![Join the chat at https://gitter.im/bhilburn/powerlevel9k](https://badges.gitter.im/bhilburn/powerlevel9k.svg)](https://gitter.im/bhilburn/powerlevel9k?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Powerlevel9k is a theme for ZSH which uses [Powerline From 02fbaf2c4befcc9a291f391a1a045d1a055332c0 Mon Sep 17 00:00:00 2001 From: Torben Hartmann Date: Tue, 5 Dec 2017 17:30:49 +0100 Subject: [PATCH 86/99] IFS Fix attemp --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 5dd394ea..fb344f25 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -695,10 +695,10 @@ set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" set_default POWERLEVEL9K_DIR_SHOW_WRITABLE false prompt_dir() { - local tmp=$IFS + local tmp="$IFS" local IFS="" local current_path=$(pwd | sed -e "s,^$HOME,~,") - local IFS=$tmp + local IFS="$tmp" if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\U2026' From d6a16bbebca41e2d78b4c03de236c56963aaccd6 Mon Sep 17 00:00:00 2001 From: Sara Murray Date: Tue, 2 Jan 2018 02:49:39 -0600 Subject: [PATCH 87/99] Corrected VPN IP command --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ae786b8..5fe57fd7 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ The segments that are currently available are: * `history` - The command number for the current line. * [`host`](#host) - Your current host name * [`ip`](#ip) - Shows the current IP address. -* [`vpn`](#vpn) - Shows the current VPN IP address. +* [`vpn_ip`](#vpn_ip) - Shows the current VPN IP address. * [`public_ip`](#public_ip) - Shows your public IP address. * [`load`](#load) - Your machine's load averages. * `os_icon` - Display a nice little icon, depending on your operating system. From 3a94826ed198ba9a569c77d163202707cda42530 Mon Sep 17 00:00:00 2001 From: LeMarsu Date: Mon, 15 Jan 2018 08:58:05 +0100 Subject: [PATCH 88/99] fix: Remove dependency of bc for load widget --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 97e99f43..14d7bd81 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -983,9 +983,9 @@ prompt_load() { # Replace comma load_avg=${load_avg//,/.} - if [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.7") ]]; then + if [[ "$load_avg" -gt $((${cores} * 0.7)) ]]; then current_state="critical" - elif [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.5") ]]; then + elif [[ "$load_avg" -gt $((${cores} * 0.5)) ]]; then current_state="warning" else current_state="normal" From afb7387abec505fb6565d31481c5f5ed724c2f08 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 2 Feb 2018 10:42:32 -0500 Subject: [PATCH 89/99] Documenting missing field from #716. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5fe57fd7..46d8ab61 100644 --- a/README.md +++ b/README.md @@ -585,6 +585,7 @@ customization is provided via: |`POWERLEVEL9K_VCS_GIT_HOOKS`|`(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname)`|Layout of the segment for git repositories.| |`POWERLEVEL9K_VCS_HG_HOOKS`|`(vcs-detect-changes)`|Layout of the segment for Mercurial repositories.| |`POWERLEVEL9K_VCS_SVN_HOOKS`|`(vcs-detect-changes svn-detect-changes)`|Layout of the segment for SVN repositories.| +|`POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND`|`red`|The color of the foreground font during actions (e.g., `REBASE`).| ##### vcs symbols From a761e3c28a78cfbf7d7ca9cde5bdcd1126c2996c Mon Sep 17 00:00:00 2001 From: Conrad Haupt Date: Mon, 12 Mar 2018 14:28:17 +0200 Subject: [PATCH 90/99] Fixed home abbreviation not being exclusive with circular navigation --- powerlevel9k.zsh-theme | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 14d7bd81..12d05db3 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -809,7 +809,9 @@ prompt_dir() { current_path="${cur_short_path: : -1}" ;; *) - current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + if [[ $current_path != "~" ]]; then + current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + fi ;; esac fi From 83ad5b598e1524fa76055f8ed086eb155c39c580 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 20 Mar 2018 22:39:20 +0100 Subject: [PATCH 91/99] Add test for wrong truncation if switching back to home folder This happens if a user switches from a subdirectory of $HOME back to the home folder and truncation strategy is "truncate folders from left". Then the folder is displayed as .../~ PR: #773 --- test/segments/dir.spec | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/segments/dir.spec b/test/segments/dir.spec index ef27e160..97bc857c 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -36,6 +36,27 @@ function testTruncateFoldersWorks() { unset POWERLEVEL9K_SHORTEN_STRATEGY } +function testTruncateFolderWithHomeDirWorks() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + CURRENT_DIR=$(pwd) + + cd ~ + FOLDER="powerlevel9k-test-${RANDOM}" + mkdir -p $FOLDER + cd $FOLDER + # Switch back to home folder as this causes the problem. + cd .. + + assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + + rmdir $FOLDER + cd ${CURRENT_DIR} + + unset CURRENT_DIR + unset FOLDER + unset POWERLEVEL9K_SHORTEN_DIR_LENGTH +} + function testTruncateMiddleWorks() { POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' From 70fa74f6313bf6a6df3c71e1c82783f6af46c7a0 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Wed, 21 Mar 2018 16:28:23 +0100 Subject: [PATCH 92/99] Fix Brightness Table --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 46d8ab61..cb5c065c 100644 --- a/README.md +++ b/README.md @@ -250,10 +250,12 @@ As with the battery stages, you can use any number of colors and Powerlevel9k will automatically use all of them appropriately. Some example settings: -|Brightness|Possible Array| -|Bright Colors|(196 202 208 214 220 226 190 154 118 82 46)| -|Normal Colors|(124 130 136 142 148 112 76 40 34 28 22)| -|Subdued Colors|( 88 94 100 106 70 34 28 22)| + +| Brightness | Possible Array | +|----------------|-------------------------------------------------| +| Bright Colors | `(196 202 208 214 220 226 190 154 118 82 46)` | +| Normal Colors | `(124 130 136 142 148 112 76 40 34 28 22)` | +| Subdued Colors | `( 88 94 100 106 70 34 28 22)` | ##### command_execution_time From 4de4e8d9d70ba3faeea31c2486632b5cb142b40d Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Thu, 22 Mar 2018 01:05:35 +0100 Subject: [PATCH 93/99] Fix POWERLEVEL9k_BATTERY_STAGES Table --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb5c065c..9991547a 100644 --- a/README.md +++ b/README.md @@ -209,8 +209,9 @@ You can also change the battery icon automatically depending on the battery level. This will override the default battery icon. In order to do this, you need to define the `POWERLEVEL9k_BATTERY_STAGES` variable. -| Variable | Default Value | Description | -| `POWERLEVEL9K_BATTERY_STAGES`|Unset|A string or array, which each index indicates a charge level.| +| Variable | Default Value | Description | +|-------------------------------|---------------|---------------------------------------------------------------| +| `POWERLEVEL9K_BATTERY_STAGES` | Unset | A string or array, which each index indicates a charge level. | Powerlevel9k will use each index of the string or array as a stage to indicate battery charge level, progressing from left to right. You can provide any number of From fe33c401bac783181e0fc53401685fa9b2ad0e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ho=CC=88ltje?= Date: Mon, 26 Mar 2018 14:55:06 -0400 Subject: [PATCH 94/99] workaround for ZSH status behavior `$pipestatus` is returning all zeros when using `[[ ]]` expressions that are false. This works around it by using `$status` (A.K.A. `$?`) when `$pipestatus` has only 1 items. Fixes #749 --- powerlevel9k.zsh-theme | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 14d7bd81..2255a04a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1163,8 +1163,13 @@ prompt_status() { local ec if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then - ec_text=$(exit_code_or_status "${RETVALS[1]}") - ec_sum=${RETVALS[1]} + if (( $#RETVALS > 1 )); then + ec_text=$(exit_code_or_status "${RETVALS[1]}") + ec_sum=${RETVALS[1]} + else + ec_text=$(exit_code_or_status "${RETVAL}") + ec_sum=${RETVAL} + fi for ec in "${(@)RETVALS[2,-1]}"; do ec_text="${ec_text}|$(exit_code_or_status "$ec")" From 9f7b0b7404a3d5307755d5e55ddc33e2e39090ba Mon Sep 17 00:00:00 2001 From: Ryan Davidson Date: Tue, 3 Apr 2018 13:52:13 +0100 Subject: [PATCH 95/99] #777 Add POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW variable to display prompt_rbenv if rbenv_version_name is the same as rbenv_global --- powerlevel9k.zsh-theme | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 14d7bd81..07902ba6 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1065,14 +1065,15 @@ prompt_ram() { "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' } +set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false # rbenv information prompt_rbenv() { - if which rbenv 2>/dev/null >&2; then + if command which rbenv 2>/dev/null >&2; then local rbenv_version_name="$(rbenv version-name)" local rbenv_global="$(rbenv global)" # Don't show anything if the current Ruby is the same as the global Ruby. - if [[ $rbenv_version_name == $rbenv_global ]]; then + if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then return fi @@ -1418,7 +1419,7 @@ prompt_kubecontext() { if [[ -z "$k8s_namespace" ]]; then k8s_namespace="default" fi - + local k8s_final_text="" if [[ "$k8s_context" == "k8s_namespace" ]]; then @@ -1427,8 +1428,8 @@ prompt_kubecontext() { else k8s_final_text="$k8s_context/$k8s_namespace" fi - - + + "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" fi } From e85fb6c93d6bc77d827133a3419d888fed5c8a4d Mon Sep 17 00:00:00 2001 From: Ryan Davidson Date: Tue, 3 Apr 2018 14:04:28 +0100 Subject: [PATCH 96/99] #777 update Readme with POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW variable description --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 46d8ab61..a04b4eea 100644 --- a/README.md +++ b/README.md @@ -511,6 +511,10 @@ It figures out the version being used by taking the output of the `rbenv version * If `rbenv` is not in $PATH, nothing will be shown. * If the current Ruby version is the same as the global Ruby version, nothing will be shown. +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW`|`false`|Set to true if you wish to show the rbenv segment even if the current Ruby version is the same as the global Ruby version| + ##### rspec_stats See [Unit Test Ratios](#unit-test-ratios), below. From 2eddce2f62ec848fb8063390e7382d7d7e07a22f Mon Sep 17 00:00:00 2001 From: Alexandre ZANNI <16578570+noraj@users.noreply.github.com> Date: Thu, 12 Apr 2018 22:54:34 +0200 Subject: [PATCH 97/99] add rvm see those files and look for `rvm` + https://github.com/bhilburn/powerlevel9k/blob/master/CHANGELOG.md + https://github.com/bhilburn/powerlevel9k/blob/master/powerlevel9k.zsh-theme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 46d8ab61..5a8ae852 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ The segments that are currently available are: * [`chruby`](#chruby) - Ruby environment information using `chruby` (if one is active). * [`rbenv`](#rbenv) - Ruby environment information using `rbenv` (if one is active). * [`rspec_stats`](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec. + * `rvm` - Ruby environment information using `$GEM_HOME` and `$MY_RUBY_HOME` (if one is active). * **Rust Segments:** * `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg). * **Swift Segments:** From 02d4e76eb4e7864a9f5ee326b6971a8407c93c4e Mon Sep 17 00:00:00 2001 From: lifehackett Date: Fri, 13 Apr 2018 08:07:43 -0600 Subject: [PATCH 98/99] Fix table formatting in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 46d8ab61..43e9cb68 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,7 @@ level. This will override the default battery icon. In order to do this, you need to define the `POWERLEVEL9k_BATTERY_STAGES` variable. | Variable | Default Value | Description | +|----------|---------------|-------------| | `POWERLEVEL9K_BATTERY_STAGES`|Unset|A string or array, which each index indicates a charge level.| Powerlevel9k will use each index of the string or array as a stage to indicate battery From cfda084eb80b76471f1b0fff5eb1332be153974f Mon Sep 17 00:00:00 2001 From: lifehackett Date: Fri, 13 Apr 2018 08:13:15 -0600 Subject: [PATCH 99/99] Another table formatting fix --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 43e9cb68..f7bab697 100644 --- a/README.md +++ b/README.md @@ -251,7 +251,9 @@ As with the battery stages, you can use any number of colors and Powerlevel9k will automatically use all of them appropriately. Some example settings: + |Brightness|Possible Array| +|----------|--------------| |Bright Colors|(196 202 208 214 220 226 190 154 118 82 46)| |Normal Colors|(124 130 136 142 148 112 76 40 34 28 22)| |Subdued Colors|( 88 94 100 106 70 34 28 22)|