From 81f7175f768d5fa653003a3cf09dd04cee0f4fb4 Mon Sep 17 00:00:00 2001 From: David Paz Date: Thu, 15 Dec 2016 13:05:23 +0100 Subject: Add service icon definition for fa-patched Add configuration for icon definitions on 'flat'|'awesome-patched' section. --- functions/icons.zsh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index 2f30cff2..a30b59f0 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -68,6 +68,9 @@ case $POWERLEVEL9K_MODE in VCS_BRANCH_ICON $'\uE220' #  VCS_REMOTE_BRANCH_ICON ' '$'\uE804 ' #  VCS_GIT_ICON $'\uE20E ' #  + VCS_GIT_GITHUB_ICON $'\uE20E ' # + VCS_GIT_BITBUCKET_ICON $'\uE20E ' # + VCS_GIT_GITLAB_ICON $'\uE20E ' # VCS_HG_ICON $'\uE1C3 ' #  VCS_SVN_ICON '(svn) ' RUST_ICON '' -- cgit v1.2.3 From e7ab1e9eedfce22364b5aeb3c8c96d1c1c766879 Mon Sep 17 00:00:00 2001 From: David Paz Date: Thu, 15 Dec 2016 13:06:32 +0100 Subject: Add service icon definition on fa-regular Add configuration for icons on section 'awesome-fontconfig'. --- functions/icons.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index a30b59f0..b6d277fc 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -124,7 +124,10 @@ case $POWERLEVEL9K_MODE in VCS_COMMIT_ICON $'\uF221 ' #  VCS_BRANCH_ICON $'\uF126' #  VCS_REMOTE_BRANCH_ICON ' '$'\uF204 ' #  - VCS_GIT_ICON $'\uF113 ' #  + VCS_GIT_ICON $'\uF1D3 ' #  + VCS_GIT_GITHUB_ICON $'\uF113 ' #  + VCS_GIT_BITBUCKET_ICON $'\uF171 ' #  + VCS_GIT_GITLAB_ICON $'\uF296 ' #  VCS_HG_ICON $'\uF0C3 ' #  VCS_SVN_ICON '(svn) ' RUST_ICON $'\uE6A8' #  -- cgit v1.2.3 From 528e648c048bff1c021e144894b050b0ce2fe7bf Mon Sep 17 00:00:00 2001 From: David Paz Date: Thu, 15 Dec 2016 13:07:15 +0100 Subject: Add service icon definition on Powerline-Patched Fonts Add configuration for service icons in section "Powerline-Patched Font". --- functions/icons.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index b6d277fc..7ae3e5a4 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -182,9 +182,12 @@ case $POWERLEVEL9K_MODE in VCS_BRANCH_ICON $'\uE0A0 ' #  VCS_REMOTE_BRANCH_ICON $'\u2192' # → VCS_GIT_ICON '' + VCS_GIT_GITHUB_ICON '' + VCS_GIT_BITBUCKET_ICON '' + VCS_GIT_GITLAB_ICON '' VCS_HG_ICON '' VCS_SVN_ICON '' - RUST_ICON '' + RUST_ICON '' PYTHON_ICON '' ) ;; -- cgit v1.2.3 From f2cac2273a662127cf9dc25471047cdd0c116701 Mon Sep 17 00:00:00 2001 From: David Paz Date: Thu, 15 Dec 2016 13:08:21 +0100 Subject: Assign git service icon depending on repo origin Check git origin url to search for well know services. Return proper icon if service found, if not return "git" icon from font-awesome icon set --- functions/vcs.zsh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'functions') diff --git a/functions/vcs.zsh b/functions/vcs.zsh index a0aa2b6c..2a461659 100644 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -110,7 +110,18 @@ function +vi-hg-bookmarks() { function +vi-vcs-detect-changes() { if [[ "${hook_com[vcs]}" == "git" ]]; then - vcs_visual_identifier='VCS_GIT_ICON' + + local remote=`git ls-remote --get-url` + if [[ "$remote" =~ "github" ]] then + vcs_visual_identifier='VCS_GIT_GITHUB_ICON' + elif [[ "$remote" =~ "bitbucket" ]] then + vcs_visual_identifier='VCS_GIT_BITBUCKET_ICON' + elif [[ "$remote" =~ "gitlab" ]] then + vcs_visual_identifier='VCS_GIT_GITLAB_ICON' + else + vcs_visual_identifier='VCS_GIT_ICON' + fi + elif [[ "${hook_com[vcs]}" == "hg" ]]; then vcs_visual_identifier='VCS_HG_ICON' elif [[ "${hook_com[vcs]}" == "svn" ]]; then -- cgit v1.2.3 From 29233c1963ce85241972e7962b92c73535e4a1d6 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Fri, 30 Dec 2016 14:04:18 -0700 Subject: added public IP segment for review/discussion --- functions/icons.zsh | 5 ++++- powerlevel9k.zsh-theme | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index 06d6ab20..b13e3463 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -76,6 +76,7 @@ case $POWERLEVEL9K_MODE in RUST_ICON '' PYTHON_ICON $'\U1F40D' # 🐍 SWIFT_ICON '' + PUBLIC_IP_ICON '' ) ;; 'awesome-fontconfig') @@ -131,9 +132,10 @@ 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 '' ) ;; *) @@ -192,6 +194,7 @@ case $POWERLEVEL9K_MODE in RUST_ICON '' PYTHON_ICON '' SWIFT_ICON 'Swift' + PUBLIC_IP_ICON '' ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9ea12aa7..34d1f640 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -426,6 +426,51 @@ prompt_battery() { fi } +prompt_public_ip() { + # set default values for segment + set_default POWERLEVEL9K_PUBLIC_IP_TIMOUT "300" + set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" + set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" + + # Do we need a fresh IP? + local refresh_ip=FALSE + if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + typeset -i timediff + timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) + [[ $timediff -gt '500' ]] && refresh_ip=TRUE + # this will run the IP refresh with each new prompt while disconnected + # but will get a new IP immediately once reconnected rather than waiting + # for the timeout, not sure if this is ideal behavior or not + [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=TRUE + else + touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=TRUE + fi + + # grab a fresh IP if needed + if [[ $refresh_ip =~ 'TRUE' && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + if type -p dig >/dev/null; then + fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" + [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip + fi + + if [[ -z "$fresh_ip" ]] && type -p curl >/dev/null; then + fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fi + + if [[ -z "$fresh_ip" ]] && type -p wget >/dev/null; then + fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fi + [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE + fi + + # write IP to tmp file + local public_ip=$(cat $POWERLEVEL9K_PUBLIC_IP_FILE) + + if [[ -n $public_ip ]]; then + $1_prompt_segment "$0" "$2" "black" "249" "${public_ip}" 'PUBLIC_IP_ICON' + fi +} + # Context: user@hostname (who am I and where am I) # Note that if $DEFAULT_USER is not set, this prompt segment will always print prompt_context() { -- cgit v1.2.3 From fa21bfff4595eb9451917ed219d29b83ea74c2e4 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Fri, 30 Dec 2016 14:10:43 -0700 Subject: reverted trailing space edit --- functions/icons.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index b13e3463..77015f0b 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -132,7 +132,7 @@ 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 '' -- cgit v1.2.3 From 95f0c3c6ecd2fc1edfd1b768150237d682426890 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 21:59:59 -0500 Subject: fixing the "OK_ICON" in 'awesome-fontconfig' which somehow got broken --- functions/icons.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index 2f30cff2..2920cfd5 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -92,7 +92,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uF291' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 - OK_ICON $'\uF23A' #  + OK_ICON $'\u2713' # ✓ FAIL_ICON $'\uF281' #  SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ -- cgit v1.2.3 From c8cc891045b6e49ff5c8c10a735af94f689dbf7f Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 22:04:16 -0500 Subject: same deal for the "FAIL_ICON"! --- functions/icons.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index 2920cfd5..5e1fcd3d 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -93,7 +93,7 @@ case $POWERLEVEL9K_MODE in TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 OK_ICON $'\u2713' # ✓ - FAIL_ICON $'\uF281' #  + FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ -- cgit v1.2.3 From 46ef589b63d62c30d52f7cfa06520989eb3ac7da Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:15:24 +0500 Subject: Add anion155's HDD segment --- functions/icons.zsh | 2 ++ powerlevel9k.zsh-theme | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) (limited to 'functions') 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' -- cgit v1.2.3 From ea648d003ec837d329c3a5d3cc53e43f9935b2a2 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 21:17:41 -0500 Subject: Moving `HDD_ICON` definition to consistent spot. --- functions/icons.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'functions') 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' -- cgit v1.2.3 From d2c0a62445dca19dfc4808d73c70d40f784b3e04 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 22:45:35 -0500 Subject: vcs icons: fixing branch spacing and remote icon in fontawesome --- functions/icons.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index 5e1fcd3d..575d1f5f 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -65,8 +65,8 @@ case $POWERLEVEL9K_MODE in VCS_TAG_ICON $'\uE817 ' #  VCS_BOOKMARK_ICON $'\uE87B' #  VCS_COMMIT_ICON $'\uE821 ' #  - VCS_BRANCH_ICON $'\uE220' #  - VCS_REMOTE_BRANCH_ICON ' '$'\uE804 ' #  + VCS_BRANCH_ICON $'\uE220 ' #  + VCS_REMOTE_BRANCH_ICON $'\u2192' # → VCS_GIT_ICON $'\uE20E ' #  VCS_HG_ICON $'\uE1C3 ' #  VCS_SVN_ICON '(svn) ' @@ -119,8 +119,8 @@ case $POWERLEVEL9K_MODE in VCS_TAG_ICON $'\uF217 ' #  VCS_BOOKMARK_ICON $'\uF27B' #  VCS_COMMIT_ICON $'\uF221 ' #  - VCS_BRANCH_ICON $'\uF126' #  - VCS_REMOTE_BRANCH_ICON ' '$'\uF204 ' #  + VCS_BRANCH_ICON $'\uF126 ' #  + VCS_REMOTE_BRANCH_ICON $'\u2192' # → VCS_GIT_ICON $'\uF113 ' #  VCS_HG_ICON $'\uF0C3 ' #  VCS_SVN_ICON '(svn) ' -- cgit v1.2.3 From 7bd2585371cc28a460543f8ef37c9f93c0d188df Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 21 Jan 2017 21:34:55 -0500 Subject: 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(-) (limited to 'functions') 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 } -- cgit v1.2.3