From 5657fe6ac7d75cac48a386f55e429b716f8d7623 Mon Sep 17 00:00:00 2001 From: Chris Chou Date: Fri, 6 Oct 2017 09:47:37 +1300 Subject: #632: Indicate `Rust` or `(rust)` for rust_version segment only if icon is unavailable --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 5aa280c6..edb94632 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1095,9 +1095,9 @@ prompt_root_indicator() { prompt_rust_version() { local rust_version rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') - + if [[ -n "$rust_version" ]]; then - "$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' + "$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "$rust_version" 'RUST_ICON' fi } # RSpec test ratio -- cgit v1.2.3 From a761e3c28a78cfbf7d7ca9cde5bdcd1126c2996c Mon Sep 17 00:00:00 2001 From: Conrad Haupt Date: Mon, 12 Mar 2018 14:28:17 +0200 Subject: Fixed home abbreviation not being exclusive with circular navigation --- powerlevel9k.zsh-theme | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'powerlevel9k.zsh-theme') 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 -- cgit v1.2.3 From b260adbc1bc68d9729d6eebcfd344f83655bfda9 Mon Sep 17 00:00:00 2001 From: Julien Roy Date: Sat, 24 Mar 2018 11:04:16 +0100 Subject: Added a segment that shows the Java version. --- README.md | 2 ++ functions/icons.zsh | 4 ++++ powerlevel9k.zsh-theme | 9 +++++++++ 3 files changed, 15 insertions(+) (limited to 'powerlevel9k.zsh-theme') diff --git a/README.md b/README.md index 46d8ab61..2686b2e7 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,8 @@ The segments that are currently available are: * `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg). * **Swift Segments:** * `swift_version` - Show the version number of the installed Swift. +* **Java Segments:** + * `java_version` - Show the current Java version. **Cloud Segments:** * **AWS Segments:** diff --git a/functions/icons.zsh b/functions/icons.zsh index 7124386b..b7da9940 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -87,6 +87,7 @@ case $POWERLEVEL9K_MODE in SSH_ICON '(ssh)' VPN_ICON '(vpn)' KUBERNETES_ICON $'\U2388' # ⎈ + JAVA_ICON $'\U2615' # ☕︎ ) ;; 'awesome-fontconfig') @@ -158,6 +159,7 @@ case $POWERLEVEL9K_MODE in SSH_ICON '(ssh)' VPN_ICON $'\uF023' KUBERNETES_ICON $'\U2388' # ⎈ + JAVA_ICON $'\U2615' # ☕︎ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -229,6 +231,7 @@ case $POWERLEVEL9K_MODE in SSH_ICON $'\uF489' #  VPN_ICON '(vpn)' KUBERNETES_ICON $'\U2388' # ⎈ + JAVA_ICON $'\U2615' # ☕︎ ) ;; *) @@ -300,6 +303,7 @@ case $POWERLEVEL9K_MODE in SSH_ICON '(ssh)' VPN_ICON '(vpn)' KUBERNETES_ICON $'\U2388' # ⎈ + JAVA_ICON $'\U2615' # ☕︎ ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 14d7bd81..e3be9c53 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1433,6 +1433,15 @@ prompt_kubecontext() { fi } +# print Java version number +prompt_java_version() { + local java_version + java_version=$(java -fullversion 2>&1 | cut -d '"' -f 2) + + if [[ -n "$java_version" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "white" "$java_version" "JAVA_ICON" + fi +} ################################################################ # Prompt processing and drawing -- cgit v1.2.3 From fe33c401bac783181e0fc53401685fa9b2ad0e24 Mon Sep 17 00:00:00 2001 From: Christian Höltje Date: Mon, 26 Mar 2018 14:55:06 -0400 Subject: 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(-) (limited to 'powerlevel9k.zsh-theme') 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")" -- cgit v1.2.3 From 9f7b0b7404a3d5307755d5e55ddc33e2e39090ba Mon Sep 17 00:00:00 2001 From: Ryan Davidson Date: Tue, 3 Apr 2018 13:52:13 +0100 Subject: #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(-) (limited to 'powerlevel9k.zsh-theme') 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 } -- cgit v1.2.3 From 05f44b94bf670d9f828b44e31ecf7b90e624fab8 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 30 Apr 2018 10:52:15 -0700 Subject: Add options for customizing `chruby` segment --- README.md | 11 +++++++++++ powerlevel9k.zsh-theme | 21 +++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/README.md b/README.md index 1f7dcadb..57018938 100644 --- a/README.md +++ b/README.md @@ -393,6 +393,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| +##### chruby + +This segment shows the version of Ruby being used when using `chruby` to change your current Ruby stack. + +It uses `$RUBY_ENGINE` and `$RUBY_VERSION` as set by `chruby`. + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_CHRUBY_SHOW_ENGINE`|true|Show the currently selected Ruby engine (e.g. `ruby`, `jruby`, `rbx`, etc) +|`POWERLEVEL9K_CHRUBY_SHOW_VERSION`|true|Shows the currently selected engine's version (e.g. `2.5.1`) + ##### 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 26ab9cd5..62f6d352 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -950,11 +950,24 @@ prompt_rbenv() { # chruby information # see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH prompt_chruby() { - local chruby_env - chrb_env="$(chruby 2> /dev/null | grep \* | tr -d '* ')" + # Uses $RUBY_VERSION and $RUBY_ENGINE set by chruby + set_default POWERLEVEL9K_CHRUBY_SHOW_VERSION true + set_default POWERLEVEL9K_CHRUBY_SHOW_ENGINE true + local chruby_label="" + + if [[ "$POWERLEVEL9K_CHRUBY_SHOW_ENGINE" == true ]]; then + chruby_label+="$RUBY_ENGINE " + fi + if [[ "$POWERLEVEL9K_CHRUBY_SHOW_VERSION" == true ]]; then + chruby_label+="$RUBY_VERSION" + fi + + # Truncate trailing spaces + chruby_label="${chruby_label%"${chruby_label##*[![:space:]]}"}" + # Don't show anything if the chruby did not change the default ruby - if [[ "${chrb_env:-system}" != "system" ]]; then - "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' + if [[ "$RUBY_ENGINE" != "" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chruby_label}" 'RUBY_ICON' fi } -- cgit v1.2.3 From 5fd171c33421fcea2af034e7a0083235f005b401 Mon Sep 17 00:00:00 2001 From: Daniel Kolsoi Date: Sat, 5 May 2018 13:25:29 -0400 Subject: Fixed prompt_rust_version to avoid grep aliases --- powerlevel9k.zsh-theme | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0e09ef03..c901103d 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1104,10 +1104,14 @@ prompt_root_indicator() { # Print Rust version number prompt_rust_version() { local rust_version - rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') + rust_version=$(command rustc --version 2>&1) + # Remove "rustc " (including the whitespace) from the beginning + # of the version string and remove everything after the next + # whitespace. This way we'll end up with only the version. + rust_version=${${rust_version/rustc /}%% *} if [[ -n "$rust_version" ]]; then - "$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' + "$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "$rust_version" 'RUST_ICON' fi } # RSpec test ratio -- cgit v1.2.3 From 3c27f14581086ab04bf7de9f69c24bdaf3e6de45 Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Tue, 8 May 2018 10:50:04 +0200 Subject: add new option "POWERLEVEL9K_BATTERY_HIDE_FULL" Hides the battery segment if percentage hits 100% --- powerlevel9k.zsh-theme | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 8f06866f..0ac0b938 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -488,14 +488,27 @@ prompt_battery() { 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" + if [[ -v "POWERLEVEL9K_BATTERY_HIDE_FULL" && "$POWERLEVEL9K_BATTERY_HIDE_FULL" == true ]]; then + if [[ "$bat_percent" != "100" ]]; then + 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 + fi else - # Draw the prompt_segment - "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + # 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 fi } -- cgit v1.2.3 From 642034eef2b455aa75819e4c394cd4416206665b Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Wed, 9 May 2018 10:18:06 +0200 Subject: remove duplicate code in battery segment --- powerlevel9k.zsh-theme | 49 ++++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0ac0b938..45d0cc25 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -488,28 +488,19 @@ prompt_battery() { fi fi - if [[ -v "POWERLEVEL9K_BATTERY_HIDE_FULL" && "$POWERLEVEL9K_BATTERY_HIDE_FULL" == true ]]; then - if [[ "$bat_percent" != "100" ]]; then - 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 - fi - else - # 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 + if [[ "${POWERLEVEL9K_BATTERY_HIDE_FULL}" == "true" && "${bat_percent}" = 100 ]]; then + return 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 } ################################################################ @@ -650,14 +641,14 @@ prompt_user() { "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "ROOT_ICON" ) - elif sudo -n true 2>/dev/null; then - user_state=( - "STATE" "SUDO" - "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" - "BACKGROUND_COLOR" "${DEFAULT_COLOR}" - "FOREGROUND_COLOR" "yellow" - "VISUAL_IDENTIFIER" "SUDO_ICON" - ) + elif sudo -n true 2>/dev/null; then + user_state=( + "STATE" "SUDO" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SUDO_ICON" + ) else user_state=( "STATE" "DEFAULT" -- cgit v1.2.3 From 238b231c3e9f76f5f2d50b2deab3696a99e2340e Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Wed, 9 May 2018 10:21:13 +0200 Subject: rename variable to POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD Variable now holds an integer, if your battery status is greater or equal to this integer the segment will be hidden --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 45d0cc25..4924d269 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -488,7 +488,7 @@ prompt_battery() { fi fi - if [[ "${POWERLEVEL9K_BATTERY_HIDE_FULL}" == "true" && "${bat_percent}" = 100 ]]; then + if [[ -v "POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD" && "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then return fi -- cgit v1.2.3 From 9b0e0c786af71048c3f615e99de079d7ff86266e Mon Sep 17 00:00:00 2001 From: Daniel Kolsoi Date: Wed, 9 May 2018 23:37:32 -0400 Subject: Removed 'Rust' text from test; Silenced missing rustc warning --- powerlevel9k.zsh-theme | 2 +- test/segments/rust_version.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c901103d..530b0d9a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1104,7 +1104,7 @@ prompt_root_indicator() { # Print Rust version number prompt_rust_version() { local rust_version - rust_version=$(command rustc --version 2>&1) + rust_version=$(command rustc --version 2>/dev/null) # Remove "rustc " (including the whitespace) from the beginning # of the version string and remove everything after the next # whitespace. This way we'll end up with only the version. diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 49b06bcf..8274789f 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -19,7 +19,7 @@ function testRust() { alias rustc=mockRust POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) - assertEquals "%K{208} %F{black}Rust 0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" + assertEquals "%K{208} %F{black}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unalias rustc -- cgit v1.2.3 From 7ab9cb150ecaef0d5fe906b9ef490b4e7c4f097d Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Sat, 12 May 2018 01:22:48 +0200 Subject: add comment line above battery-threshold condition --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 4924d269..8e6bf9ad 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -487,7 +487,7 @@ prompt_battery() { [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} fi fi - + # return if POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD is set and the battery percentage is greater or equal if [[ -v "POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD" && "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then return fi -- cgit v1.2.3 From 27bd1cd65df8878812adefcf1ab6974660c2714d Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sat, 12 May 2018 23:17:49 +0200 Subject: Fix test for rust segment --- powerlevel9k.zsh-theme | 1 + test/segments/rust_version.spec | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 530b0d9a..2b21b3de 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1114,6 +1114,7 @@ prompt_rust_version() { "$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "$rust_version" 'RUST_ICON' fi } + # RSpec test ratio prompt_rspec_stats() { if [[ (-d app && -d spec) ]]; then diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 8274789f..85b4ec69 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -5,28 +5,39 @@ setopt shwordsplit SHUNIT_PARENT=$0 +TEST_BASE_FOLDER=/tmp/powerlevel9k-test +RUST_TEST_FOLDER="${TEST_BASE_FOLDER}/rust-test" + function setUp() { + OLDPATH="${PATH}" + mkdir -p "${RUST_TEST_FOLDER}" + PATH="${RUST_TEST_FOLDER}:${PATH}" + export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme } +function tearDown() { + PATH="${OLDPATH}" + rm -fr "${TEST_BASE_FOLDER}" +} + function mockRust() { - echo 'rustc 0.4.1a-alpha' + echo "#!/bin/sh\n\necho 'rustc 0.4.1a-alpha'" > "${RUST_TEST_FOLDER}/rustc" + chmod +x "${RUST_TEST_FOLDER}/rustc" } function testRust() { - alias rustc=mockRust + mockRust POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) assertEquals "%K{208} %F{black}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unalias rustc } function testRustPrintsNothingIfRustIsNotAvailable() { - alias rustc=noRust POWERLEVEL9K_CUSTOM_WORLD='echo world' POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version) @@ -34,7 +45,6 @@ function testRustPrintsNothingIfRustIsNotAvailable() { unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_CUSTOM_WORLD - unalias rustc } source shunit2/source/2.1/src/shunit2 -- cgit v1.2.3 From 557f5993ea7c8ae1fb196bcb21c4e9fd9dee26ce Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Thu, 17 May 2018 12:08:04 +0200 Subject: add cog symbol to dir segment if folder is /etc* --- functions/icons.zsh | 5 +++++ powerlevel9k.zsh-theme | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/functions/icons.zsh b/functions/icons.zsh index f758d55c..742d8d36 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -71,6 +71,7 @@ case $POWERLEVEL9K_MODE in HOME_SUB_ICON $'\uE18D' #  FOLDER_ICON $'\uE818' #  NETWORK_ICON $'\uE1AD' #  + ETC_ICON $'\uE818' #  LOAD_ICON $'\uE190 ' #  SWAP_ICON $'\uE87D' #  RAM_ICON $'\uE1E2 ' #  @@ -167,6 +168,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON $'\uF015' #  HOME_SUB_ICON $'\uF07C' #  FOLDER_ICON $'\uF115' #  + ETC_ICON $'\uF013' #  NETWORK_ICON $'\uF09E' #  LOAD_ICON $'\uF080 ' #  SWAP_ICON $'\uF0E4' #  @@ -266,6 +268,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  + ETC_ICON $'\uF013' #  NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS #  LOAD_ICON '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  @@ -359,6 +362,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON $'\uF015' #  HOME_SUB_ICON $'\uF07C' #  FOLDER_ICON $'\uF115' #  + ETC_ICON $'\uF013' #  NETWORK_ICON $'\uF1EB' #  LOAD_ICON $'\uF080 ' #  SWAP_ICON $'\uF464' #  @@ -452,6 +456,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON '' HOME_SUB_ICON '' FOLDER_ICON '' + ETC_ICON $'\uF013' #  NETWORK_ICON 'IP' LOAD_ICON 'L' SWAP_ICON 'SWP' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 8f06866f..b6493fed 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -909,10 +909,13 @@ prompt_dir() { "HOME" "HOME_ICON" "HOME_SUBFOLDER" "HOME_SUB_ICON" "NOT_WRITABLE" "LOCK_ICON" + "ETC" "ETC_ICON" ) local state_path="$(print -P '%~')" local current_state="DEFAULT" - if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then + if [[ $state_path == '/etc'* ]]; then + current_state='ETC' + elif [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then current_state="NOT_WRITABLE" elif [[ $state_path == '~' ]]; then current_state="HOME" -- cgit v1.2.3 From 37cbc9a02d16b1d152dcc2c6af51214d316639d3 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sat, 26 May 2018 00:27:36 +0200 Subject: Fix RPROMPT placement This fixes #841 --- powerlevel9k.zsh-theme | 2 +- test/powerlevel9k.spec | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 8f06866f..e201d35c 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1740,7 +1740,7 @@ $(print_icon 'MULTILINE_LAST_PROMPT_PREFIX')' fi if [[ "$POWERLEVEL9K_DISABLE_RPROMPT" != true ]]; then - RPROMPT='$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX' + RPROMPT="${RPROMPT_PREFIX}"'%f%b%k$(build_right_prompt)%{$reset_color%}'"${RPROMPT_SUFFIX}" fi local NEWLINE=' diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index 5f6b6f27..4178a4f6 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -114,4 +114,23 @@ function testOverwritingIconsWork() { # rm -fr ~/$testFolder } +function testNewlineOnRpromptCanBeDisabled() { + POWERLEVEL9K_PROMPT_ON_NEWLINE=true + POWERLEVEL9K_RPROMPT_ON_NEWLINE=false + POWERLEVEL9K_CUSTOM_WORLD='echo world' + POWERLEVEL9K_CUSTOM_RWORLD='echo rworld' + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world) + POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_rworld) + + powerlevel9k_prepare_prompts + assertEquals '$(print_icon MULTILINE_FIRST_PROMPT_PREFIX) world  $(print_icon MULTILINE_LAST_PROMPT_PREFIX) rworld ' "$(print -P ${PROMPT}${RPROMPT})" + + unset POWERLEVEL9K_PROMPT_ON_NEWLINE + unset POWERLEVEL9K_RPROMPT_ON_NEWLINE + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS + unset POWERLEVEL9K_CUSTOM_WORLD + unset POWERLEVEL9K_CUSTOM_RWORLD +} + source shunit2/source/2.1/src/shunit2 -- cgit v1.2.3 From 2f95fd04d94a5b2fed33f17ecd1c1d7bab5ad44a Mon Sep 17 00:00:00 2001 From: Yang Tang Date: Fri, 1 Jun 2018 11:49:23 -0400 Subject: Fix icons cut off in some terminal emulators --- powerlevel9k.zsh-theme | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0e09ef03..836d4ae0 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -156,12 +156,12 @@ left_prompt_segment() { if [[ -n $6 ]]; then visual_identifier="$(print_icon $6)" if [[ -n "$visual_identifier" ]]; then + # Add an whitespace if we print more than just the visual identifier + [[ -n "$5" ]] && visual_identifier="$visual_identifier " # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR set_default $visual_identifier_color_variable $4 visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n "$5" ]] && visual_identifier="$visual_identifier " fi fi @@ -240,12 +240,12 @@ right_prompt_segment() { if [[ -n "$6" ]]; then visual_identifier="$(print_icon $6)" if [[ -n "$visual_identifier" ]]; then + # Add an whitespace if we print more than just the visual identifier + [[ -n "$5" ]] && visual_identifier=" $visual_identifier" # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR set_default $visual_identifier_color_variable $4 visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n "$5" ]] && visual_identifier=" $visual_identifier" fi fi -- cgit v1.2.3 From 9c4203bdf80440b43b5f559b5d8856f6b817ad9e Mon Sep 17 00:00:00 2001 From: Yang Tang Date: Fri, 1 Jun 2018 14:18:18 -0400 Subject: Add comments about the whitespace and coloring --- powerlevel9k.zsh-theme | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 836d4ae0..b8d4b0cc 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -156,7 +156,9 @@ left_prompt_segment() { if [[ -n $6 ]]; then visual_identifier="$(print_icon $6)" if [[ -n "$visual_identifier" ]]; then - # Add an whitespace if we print more than just the visual identifier + # Add an whitespace if we print more than just the visual identifier. + # To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st), + # we need to color both the visual identifier and the whitespace. [[ -n "$5" ]] && visual_identifier="$visual_identifier " # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR @@ -240,7 +242,9 @@ right_prompt_segment() { if [[ -n "$6" ]]; then visual_identifier="$(print_icon $6)" if [[ -n "$visual_identifier" ]]; then - # Add an whitespace if we print more than just the visual identifier + # Add an whitespace if we print more than just the visual identifier. + # To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st), + # we need to color both the visual identifier and the whitespace. [[ -n "$5" ]] && visual_identifier=" $visual_identifier" # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR -- cgit v1.2.3 From a2d8cccd098bc1f739c324623bdabb701e65ba90 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 1 May 2018 02:10:26 +0200 Subject: Add a Laravel version segment --- CHANGELOG.md | 6 ++++++ README.md | 1 + functions/icons.zsh | 5 +++++ powerlevel9k.zsh-theme | 12 ++++++++++++ 4 files changed, 24 insertions(+) (limited to 'powerlevel9k.zsh-theme') diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a8842a3..e7e61af6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## next + +### New Segment: `laravel_version` + +Displays the current laravel version. + ## v0.6.4 - `load` segment now has configurable averages. diff --git a/README.md b/README.md index 9b86067f..1e01e915 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ The segments that are currently available are: * `nvm` - Show the version of Node that is currently active, if it differs from the version used by NVM * **PHP Segments:** * `php_version` - Show the current PHP version. + * `laravel_version` - Show the current Laravel version. * [`symfony2_tests`](#symfony2_tests) - Show a ratio of test classes vs code classes for Symfony2. * `symfony2_version` - Show the current Symfony2 version, if you are in a Symfony2-Project dir. * **Python Segments:** diff --git a/functions/icons.zsh b/functions/icons.zsh index 1f90e94f..98c6f13d 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -111,6 +111,7 @@ case $POWERLEVEL9K_MODE in DATE_ICON $'\uE184' #  TIME_ICON $'\uE12E' #  JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' ) ;; 'awesome-fontconfig') @@ -206,6 +207,7 @@ case $POWERLEVEL9K_MODE in DATE_ICON $'\uF073 ' #  TIME_ICON $'\uF017 ' #  JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' ) ;; 'awesome-mapped-fontconfig') @@ -306,6 +308,7 @@ case $POWERLEVEL9K_MODE in DATE_ICON $'\uF073 ' #  TIME_ICON $'\uF017 ' #  JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -402,6 +405,7 @@ case $POWERLEVEL9K_MODE in DATE_ICON $'\uF073 ' #  TIME_ICON $'\uF017 ' #  JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON $'\ue73f ' #  ) ;; *) @@ -497,6 +501,7 @@ case $POWERLEVEL9K_MODE in DATE_ICON '' TIME_ICON '' JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b9119d4c..dde838d9 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1109,6 +1109,18 @@ prompt_vpn_ip() { done } +################################################################ +# Segment to display laravel version +prompt_laravel_version() { + local laravel_version="$(php artisan --version 2>/dev/null)" + if [[ -n "${laravel_version}" ]]; then + # Remove unrelevant infos + laravel_version="${laravel_version//Laravel Framework version /}" + + "$1_prompt_segment" "$0" "$2" "maroon" "white" "${laravel_version}" 'LARAVEL_ICON' + fi +} + ################################################################ # Segment to display load set_default POWERLEVEL9K_LOAD_WHICH 5 -- cgit v1.2.3 From dc21b973350a1ebc0a6ff1699e2d8439a9f8820c Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 7 Jun 2018 02:01:36 +0200 Subject: Fix travis build --- powerlevel9k.zsh-theme | 3 ++- test/segments/laravel_version.spec | 2 +- test/segments/rust_version.spec | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index dde838d9..59178708 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1307,7 +1307,8 @@ prompt_root_indicator() { ################################################################ # Segment to display Rust version number prompt_rust_version() { - local rust_version=$(command rustc --version 2>/dev/null) + local rust_version + rust_version=$(command rustc --version 2>/dev/null) # Remove "rustc " (including the whitespace) from the beginning # of the version string and remove everything after the next # whitespace. This way we'll end up with only the version. diff --git a/test/segments/laravel_version.spec b/test/segments/laravel_version.spec index bebbfcfc..40b130d2 100755 --- a/test/segments/laravel_version.spec +++ b/test/segments/laravel_version.spec @@ -31,7 +31,7 @@ function testLaravelVersionSegment() { POWERLEVEL9K_LARAVEL_ICON='x' POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(laravel_version) - assertEquals "%K{001} %F{white%}x%f %F{white}5.4.23 %k%F{maroon}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{white%}x %f%F{white}5.4.23 %k%F{maroon}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LARAVEL_ICON diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 2a344f64..34883a10 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -32,7 +32,7 @@ function testRust() { mockRust POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) - assertEquals "%K{208} %F{black%}Rust%f %F{black}0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" + assertEquals "%K{208} %F{black%}Rust %f%F{black}0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS } -- cgit v1.2.3 From 51b53cd4b5e715ae148ba588ea573491cdcc17c5 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sat, 9 Jun 2018 14:37:56 +0200 Subject: Fix `rbenv` segment after merge --- powerlevel9k.zsh-theme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 59178708..730cff49 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1262,12 +1262,13 @@ prompt_rbenv() { 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 # unless `POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW` is set. if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then return fi + + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' fi } -- cgit v1.2.3 From 3989834bfef217115dc2ceb20cfbd6f3ac717756 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Thu, 14 Jun 2018 21:41:13 -0600 Subject: Hide one-space indent at right margin ZSH displays the right prompt indented one space from the right margin. This can be tweaked with ZLE_RPROMPT_INDENT=0, but that makes display problems very likely and I don't recommend it. But all is not lost. The %E prompt format does continue the current background color through that last indent space. So it can *look* like our prompt goes right up to the margin, if: 1) We remove the trailing space from the last segment, and 2) We add %E before clearing the background color --- powerlevel9k.zsh-theme | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0e09ef03..61dfdba0 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -222,6 +222,12 @@ right_prompt_segment() { [[ -n "$4" ]] && fg="%F{$4}" || fg="%f" # If CURRENT_RIGHT_BG is "NONE", we are the first right segment. + + if [[ "$CURRENT_RIGHT_BG" != "NONE" ]]; then + # This is the closing whitespace for the previous segment + echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" + fi + if [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]]; then if isSameColor "$CURRENT_RIGHT_BG" "$3"; then # Middle segment with same color as previous segment @@ -257,7 +263,7 @@ right_prompt_segment() { # Print segment content if there is any [[ -n "$5" ]] && echo -n "${5}" # Print the visual identifier - echo -n "${visual_identifier}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" + echo -n "${visual_identifier}" CURRENT_RIGHT_BG=$3 last_right_element_index=$current_index @@ -1484,6 +1490,9 @@ build_right_prompt() { index=$((index + 1)) done + + # Clear to the end of the line + echo -n "%E" } powerlevel9k_preexec() { -- cgit v1.2.3 From d09a46f9e017541dc350dc44bf519d3d77ccd4e4 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 17 Jun 2018 22:47:43 +0200 Subject: Mute errors when asking for java version --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 730cff49..0a6cc055 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1707,7 +1707,7 @@ prompt_dropbox() { # print Java version number prompt_java_version() { local java_version - java_version=$(java -fullversion 2>&1 | cut -d '"' -f 2) + java_version=$(java -fullversion 2>/dev/null | cut -d '"' -f 2) if [[ -n "$java_version" ]]; then "$1_prompt_segment" "$0" "$2" "red" "white" "$java_version" "JAVA_ICON" -- cgit v1.2.3 From bda3171237e83ab7fd47d5b2fa6c2d3f44f02e92 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 20 Jun 2018 22:55:14 +0200 Subject: Fix java_version segment --- powerlevel9k.zsh-theme | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 05a75489..ff3a9466 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1713,7 +1713,12 @@ prompt_dropbox() { # print Java version number prompt_java_version() { local java_version - java_version=$(java -fullversion 2>/dev/null | cut -d '"' -f 2) + # Stupid: Java prints its version on STDERR. + # The first version ouput will print nothing, we just + # use it to transport whether the command was successful. + # If yes, we parse the version string (and need to + # redirect the stderr to stdout to make the pipe work). + java_version=$(java -version 2>/dev/null && java -fullversion 2>&1 | cut -d '"' -f 2) if [[ -n "$java_version" ]]; then "$1_prompt_segment" "$0" "$2" "red" "white" "$java_version" "JAVA_ICON" -- cgit v1.2.3