From 46ef589b63d62c30d52f7cfa06520989eb3ac7da Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:15:24 +0500 Subject: [PATCH 01/17] Add anion155's HDD segment --- functions/icons.zsh | 2 ++ powerlevel9k.zsh-theme | 44 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/functions/icons.zsh b/functions/icons.zsh index eb526f0b..e5cfe6f2 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -34,6 +34,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uE891' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\uE894' #  + HDD_ICON $'\uD83D\uDDB4' # 🖴 OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' @@ -97,6 +98,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uF291' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 + HDD_ICON $'\uF0A0 ' #  OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c3f2be74..7d948800 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -337,6 +337,50 @@ prompt_background_jobs() { fi } +# Segment to indicate hdd available level. +prompt_hdd_usage() { + local current_state="unknown" + typeset -AH hdd_usage_states + hdd_usage_states=( + 'normal' 'green' + 'warning' 'yellow' + 'critical' 'red' + ) + + # local df="$(df -k . | sed -n '2p')" + # local size="$(echo $df | awk '{ print $2 }')" + # local avail="$(echo $df | awk '{ print $4 }')" + # local level="$(printf %.0f $(( avail * 100.0 / size )))" + local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" + level="$(( 100 - level ))" + + set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 10 + set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 5 + + if [ $level -gt $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then + # Default behavior: Show message always + set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false + if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then + return + fi + fi + + current_state='normal' + if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then + current_state='warning' + fi + if [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then + current_state='critical' + fi + + local message="$level" + + # Draw the prompt_segment + if [[ -n $level ]]; then + "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${hdd_usage_states[$current_state]}" "$message" 'HDD_ICON' + fi +} + prompt_battery() { # The battery can have four different states - default to 'unknown'. local current_state='unknown' From 41588e0d249d328ef862b779b1c8ef752a94ca81 Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:24:31 +0500 Subject: [PATCH 02/17] Change colors --- powerlevel9k.zsh-theme | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 7d948800..f5208c72 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -340,9 +340,15 @@ prompt_background_jobs() { # Segment to indicate hdd available level. prompt_hdd_usage() { local current_state="unknown" - typeset -AH hdd_usage_states - hdd_usage_states=( - 'normal' 'green' + typeset -AH hdd_usage_forecolors + hdd_usage_forecolors=( + 'normal' 'yellow' + 'warning' "$DEFAULT_COLOR" + 'critical' 'white' + ) + typeset -AH hdd_usage_backcolors + hdd_usage_backcolors=( + 'normal' $DEFAULT_COLOR 'warning' 'yellow' 'critical' 'red' ) @@ -366,18 +372,20 @@ prompt_hdd_usage() { fi current_state='normal' + local message="$level%" + if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then current_state='warning' + message="$message left" fi if [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then current_state='critical' + message="$message left" fi - local message="$level" - # Draw the prompt_segment if [[ -n $level ]]; then - "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${hdd_usage_states[$current_state]}" "$message" 'HDD_ICON' + "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'HDD_ICON' fi } From 32708784b25f671db09fd3224b4e2d910a48dbbb Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:25:34 +0500 Subject: [PATCH 03/17] Fix --- powerlevel9k.zsh-theme | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f5208c72..1387ecea 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -377,8 +377,7 @@ prompt_hdd_usage() { if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then current_state='warning' message="$message left" - fi - if [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then + elif [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then current_state='critical' message="$message left" fi From cf8a94de0167a743da3f38b1ca6ea44903ef66e9 Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:26:32 +0500 Subject: [PATCH 04/17] Fix --- powerlevel9k.zsh-theme | 2 -- 1 file changed, 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 1387ecea..6b5decbf 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -376,10 +376,8 @@ prompt_hdd_usage() { if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then current_state='warning' - message="$message left" elif [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then current_state='critical' - message="$message left" fi # Draw the prompt_segment From 934186df6d35762f877bb7943db0534f0e50babc Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:27:33 +0500 Subject: [PATCH 05/17] Fix --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 6b5decbf..473e17b0 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -372,7 +372,7 @@ prompt_hdd_usage() { fi current_state='normal' - local message="$level%" + local message="$level% " if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then current_state='warning' From 92cb8d14d1afe25ee8cd2d634cf4948d56921afb Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:28:24 +0500 Subject: [PATCH 06/17] Fix --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 473e17b0..9a1a9100 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -372,7 +372,7 @@ prompt_hdd_usage() { fi current_state='normal' - local message="$level% " + local message="${level}%" if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then current_state='warning' From ea74c45d4fd1a277cba5b694025bdfa29aa52645 Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:39:40 +0500 Subject: [PATCH 07/17] Fix --- powerlevel9k.zsh-theme | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9a1a9100..53862b8c 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -338,6 +338,9 @@ prompt_background_jobs() { } # Segment to indicate hdd available level. +set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false +set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 10 +set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 5 prompt_hdd_usage() { local current_state="unknown" typeset -AH hdd_usage_forecolors @@ -357,28 +360,28 @@ prompt_hdd_usage() { # local size="$(echo $df | awk '{ print $2 }')" # local avail="$(echo $df | awk '{ print $4 }')" # local level="$(printf %.0f $(( avail * 100.0 / size )))" - local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" - level="$(( 100 - level ))" - set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 10 - set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 5 + # local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" + # level="$(( 100 - level ))" + # level="3" - if [ $level -gt $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then + set_default level 10 + + if [ "$level" -gt "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then # Default behavior: Show message always - set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then return fi fi - current_state='normal' - local message="${level}%" - - if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then - current_state='warning' - elif [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then + if [ "$level" -le "$POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL" ]; then current_state='critical' + elif [ "$level" -le "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then + current_state='warning' + else + current_state='normal' fi + local message="${level}%%" # Draw the prompt_segment if [[ -n $level ]]; then From 7f3677d22a6d6010013e9f17284b70ac84126f3e Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:41:54 +0500 Subject: [PATCH 08/17] Fix --- powerlevel9k.zsh-theme | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 53862b8c..bee48295 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -361,11 +361,8 @@ prompt_hdd_usage() { # local avail="$(echo $df | awk '{ print $4 }')" # local level="$(printf %.0f $(( avail * 100.0 / size )))" - # local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" - # level="$(( 100 - level ))" - # level="3" - - set_default level 10 + local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" + level="$(( 100 - level ))" if [ "$level" -gt "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then # Default behavior: Show message always From ea648d003ec837d329c3a5d3cc53e43f9935b2a2 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 21:17:41 -0500 Subject: [PATCH 09/17] Moving `HDD_ICON` definition to consistent spot. --- functions/icons.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index e5cfe6f2..d2ca9488 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -34,7 +34,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uE891' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\uE894' #  - HDD_ICON $'\uD83D\uDDB4' # 🖴 + HDD_ICON $'\uF0A0 ' #  OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' @@ -158,6 +158,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON '' TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 + HDD_ICON $'HDD ' OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' From 59b20b8f2780b8a0a3c812cd292393005a1638cb Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 21:45:11 -0500 Subject: [PATCH 10/17] changing `hdd_usage` to actually show usage --- powerlevel9k.zsh-theme | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bee48295..ec4c60c3 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -337,10 +337,10 @@ prompt_background_jobs() { fi } -# Segment to indicate hdd available level. +# Segment that indicates usage level of current partition. set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false -set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 10 -set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 5 +set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 90 +set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 95 prompt_hdd_usage() { local current_state="unknown" typeset -AH hdd_usage_forecolors @@ -356,28 +356,20 @@ prompt_hdd_usage() { 'critical' 'red' ) - # local df="$(df -k . | sed -n '2p')" - # local size="$(echo $df | awk '{ print $2 }')" - # local avail="$(echo $df | awk '{ print $4 }')" - # local level="$(printf %.0f $(( avail * 100.0 / size )))" - local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" - level="$(( 100 - level ))" - - if [ "$level" -gt "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then - # Default behavior: Show message always - if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then - return - fi - fi - if [ "$level" -le "$POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL" ]; then - current_state='critical' - elif [ "$level" -le "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then + if [ "$level" -ge "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then current_state='warning' + if [ "$level" -ge "$POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL" ]; then + current_state='critical' + fi else + if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then + return + fi current_state='normal' fi + local message="${level}%%" # Draw the prompt_segment From 64afe83cbd368d45c0ab23c05636b426230fcb57 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 22:24:03 -0500 Subject: [PATCH 11/17] Updating the readme wih `hdd_usage` details. --- CHANGELOG.md | 4 ++++ README.md | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8060e0fa..d21ecaa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Added an option to configure the path separator. If you want something else than an ordinary slash, you could set `POWERLEVEL9K_DIR_PATH_SEPARATOR` to whatever you want. +### New segment 'hdd_usage' added + +This segment will show the usage level of your current partition. + ## v0.5.0 ### `load` and `ram` changes diff --git a/README.md b/README.md index f6b8c54c..b1bdf978 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ The segments that are currently available are: * [`battery`](#battery) - Current battery status. * [`context`](#context) - Your username and host. * [`dir`](#dir) - Your current working directory. +* [`hdd_usage`](#hdd_usage) - Disk usage of your current partition. * `history` - The command number for the current line. * [`ip`](#ip) - Shows the current IP address. * [`public_ip`](#public_ip) - Shows your public IP address. @@ -306,6 +307,16 @@ If you want to customize the directory separator, you could set: POWERLEVEL9K_DIR_PATH_SEPARATOR="%f "$'\uE0B1'" %F" ``` +##### hdd_usage + +The `hdd_usage` segment will show the usage level of the partition that your current working directory resides in. It can be configured with the following variables. + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|POWERLEVEL9K_HDD_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.| +|POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.| +|POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.| + ##### ip This segment tries to examine all currently used network interfaces and prints From b8e18d710835ff4a3dbd7b19799b731d5930ccbd Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 22 Jan 2017 01:47:58 +0100 Subject: [PATCH 12/17] Fix swift segment The regex for the swift segment matches too much. Here I simplified it to match the first number as this is probably the "main" version number. --- powerlevel9k.zsh-theme | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c3f2be74..dd904278 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1065,12 +1065,10 @@ prompt_pyenv() { # Swift version prompt_swift_version() { - local swift_version=($(swift --version 2>/dev/null)) + # Get the first number as this is probably the "main" version number.. + local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1) [[ -z "${swift_version}" ]] && return - # Extract semantic version - swift_version=$(echo ${swift_version} | sed -e 's/[^0-9.]*\([0-9.]*\).*/\1/') - "$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON' } From 7bd2585371cc28a460543f8ef37c9f93c0d188df Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 21 Jan 2017 21:34:55 -0500 Subject: [PATCH 13/17] incorportaing feedback from review on `hdd_usage` segment --- README.md | 12 ++++++------ functions/icons.zsh | 6 +++--- powerlevel9k.zsh-theme | 23 ++++++++++++----------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index b1bdf978..0d3eb303 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ The segments that are currently available are: * [`battery`](#battery) - Current battery status. * [`context`](#context) - Your username and host. * [`dir`](#dir) - Your current working directory. -* [`hdd_usage`](#hdd_usage) - Disk usage of your current partition. +* [`disk_usage`](#disk_usage) - Disk usage of your current partition. * `history` - The command number for the current line. * [`ip`](#ip) - Shows the current IP address. * [`public_ip`](#public_ip) - Shows your public IP address. @@ -307,15 +307,15 @@ If you want to customize the directory separator, you could set: POWERLEVEL9K_DIR_PATH_SEPARATOR="%f "$'\uE0B1'" %F" ``` -##### hdd_usage +##### disk_usage -The `hdd_usage` segment will show the usage level of the partition that your current working directory resides in. It can be configured with the following variables. +The `disk_usage` segment will show the usage level of the partition that your current working directory resides in. It can be configured with the following variables. | Variable | Default Value | Description | |----------|---------------|-------------| -|POWERLEVEL9K_HDD_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.| -|POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.| -|POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.| +|POWERLEVEL9K_DISK_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.| +|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.| ##### ip diff --git a/functions/icons.zsh b/functions/icons.zsh index d2ca9488..84483b40 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -34,7 +34,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uE891' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\uE894' #  - HDD_ICON $'\uF0A0 ' #  + DISK_ICON $'\uE1AE ' #  OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' @@ -98,7 +98,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uF291' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 - HDD_ICON $'\uF0A0 ' #  + DISK_ICON $'\uF0A0 ' #  OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' @@ -158,7 +158,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON '' TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 - HDD_ICON $'HDD ' + DISK_ICON $'hdd ' OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index ec4c60c3..f2e32582 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -338,10 +338,10 @@ prompt_background_jobs() { } # Segment that indicates usage level of current partition. -set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false -set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 90 -set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 95 -prompt_hdd_usage() { +set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false +set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 +set_default POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL 95 +prompt_disk_usage() { local current_state="unknown" typeset -AH hdd_usage_forecolors hdd_usage_forecolors=( @@ -356,25 +356,26 @@ prompt_hdd_usage() { 'critical' 'red' ) - local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" + local disk_usage="${$(\df -P . | sed -n '2p' | awk '{ print $5 }')%%\%}" - if [ "$level" -ge "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then + if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL" ]; then current_state='warning' - if [ "$level" -ge "$POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL" ]; then + if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL" ]; then current_state='critical' fi else - if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then + if [[ "$POWERLEVEL9K_DISK_USAGE_ONLY_WARNING" == true ]]; then + current_state='' return fi current_state='normal' fi - local message="${level}%%" + local message="${disk_usage}%%" # Draw the prompt_segment - if [[ -n $level ]]; then - "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'HDD_ICON' + if [[ -n $disk_usage ]]; then + "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' fi } From 81e9fef9e9ed95499c572415eaa78b343746068f Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 21 Jan 2017 21:38:45 -0500 Subject: [PATCH 14/17] updating changelog for segment name change `disk_usage` --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d21ecaa5..ff0fd890 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Added an option to configure the path separator. If you want something else than an ordinary slash, you could set `POWERLEVEL9K_DIR_PATH_SEPARATOR` to whatever you want. -### New segment 'hdd_usage' added +### New segment 'disk_usage' added This segment will show the usage level of your current partition. From 1a2439926fb1df356e9ca0bc5ca937c01c64fcd2 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sun, 22 Jan 2017 13:13:11 -0500 Subject: [PATCH 15/17] README: default segment list was no longer accurate --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0d3eb303..840ee156 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,8 @@ Here is `powerlevel9k` in action, with [some simple settings](https://github.com Be sure to also [check out the Wiki](https://github.com/bhilburn/powerlevel9k/wiki)! ### Installation -There are two installation steps to go from a lame terminal to a "Power Level -9000" terminal. Once you are done, you can optionally customize your prompt. +There are two installation steps to go from a vanilla terminal to a PL9k +terminal. Once you are done, you can optionally customize your prompt. [Installation Instructions](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions) @@ -71,14 +71,15 @@ variables to your `~/.zshrc`. | Variable | Default Value | Description | |----------|---------------|-------------| |`POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`|`(context dir rbenv vcs)`|Segment list for left prompt| -|`POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`|`(status history time)`|Segment list for right prompt| +|`POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`|`(status root_indicator background_jobs history time)`|Segment list for right prompt| -So if you wanted to set these variables manually, you would put the following in +The table above shows the default values, so if you wanted to set these +variables manually, you would put the following in your `~/.zshrc`: ```zsh POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) -POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time) +POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) ``` #### Available Prompt Segments The segments that are currently available are: From eb67fb5c0c0b504fbbcc6c56433ffe09393dfe7a Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sun, 22 Jan 2017 13:22:33 -0500 Subject: [PATCH 16/17] README: fixing name of `detect-virt` to `detect_virt` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 840ee156..f7a80a09 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ The segments that are currently available are: * [`custom_command`](#custom_command) - Create a custom segment to display the output of an arbitrary command. * [`todo`](http://todotxt.com/) - Shows the number of tasks in your todo.txt tasks file. -* `detect-virt` - Virtualization detection with systemd +* `detect_virt` - Virtualization detection with systemd --------------------------------------------------------------------------------- From a95b4740a6226ed4d1e82305a6f05e59a03ae65e Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sun, 22 Jan 2017 13:22:55 -0500 Subject: [PATCH 17/17] CHANGELOG: Updating to reflect work on `next` --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0fd890..defc1dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ ## next +- Fixed a bug where the tag display was broken on detached HEADs. +- Fixed a bug where SVN detection sometimes failed. +- Fixed the `load` and `ram` segments for BSD. +- Fixed code-points that changed in Awesome fonts. +- Fixed display of "OK_ICON" in `status` segment in non-verbose mode. +- Fixed an issue where dir name truncation that was very short sometimes failed. +- Speed & accuracy improvements to the battery segment. +- Added Github syntax highlighting to README. +- Various documentation cleanup. + +### `vcs` changes + +The VCS segment can now display icons for remote repo hosting services, including Github, Gitlab, and 'other'. + ### `dir` changes Added an option to configure the path separator. If you want something @@ -10,6 +24,18 @@ else than an ordinary slash, you could set This segment will show the usage level of your current partition. +### New segment 'public_ip' added + +Fetches your Public IP (using ident.me) and displays it in your prompt. + +### New segment 'swift_version' added + +This segment displays the version of Swift that is installed / in your path. + +### New segment 'detect_virt' added + +Detects and reports if you are in a virtualized session using `systemd`. + ## v0.5.0 ### `load` and `ram` changes