From 46ef589b63d62c30d52f7cfa06520989eb3ac7da Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:15:24 +0500 Subject: [PATCH 01/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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 7bd2585371cc28a460543f8ef37c9f93c0d188df Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 21 Jan 2017 21:34:55 -0500 Subject: [PATCH 12/13] 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 13/13] 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.