mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
incorportaing feedback from review on hdd_usage
segment
This commit is contained in:
parent
64afe83cbd
commit
7bd2585371
3 changed files with 21 additions and 20 deletions
12
README.md
12
README.md
|
@ -88,7 +88,7 @@ The segments that are currently available are:
|
||||||
* [`battery`](#battery) - Current battery status.
|
* [`battery`](#battery) - Current battery status.
|
||||||
* [`context`](#context) - Your username and host.
|
* [`context`](#context) - Your username and host.
|
||||||
* [`dir`](#dir) - Your current working directory.
|
* [`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.
|
* `history` - The command number for the current line.
|
||||||
* [`ip`](#ip) - Shows the current IP address.
|
* [`ip`](#ip) - Shows the current IP address.
|
||||||
* [`public_ip`](#public_ip) - Shows your public 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"
|
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 |
|
| Variable | Default Value | Description |
|
||||||
|----------|---------------|-------------|
|
|----------|---------------|-------------|
|
||||||
|POWERLEVEL9K_HDD_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.|
|
|POWERLEVEL9K_DISK_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_DISK_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_CRITICAL_LEVEL|95|The usage level that triggers a critical state.|
|
||||||
|
|
||||||
##### ip
|
##### ip
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
TEST_ICON $'\uE891' #
|
TEST_ICON $'\uE891' #
|
||||||
TODO_ICON $'\u2611' # ☑
|
TODO_ICON $'\u2611' # ☑
|
||||||
BATTERY_ICON $'\uE894' #
|
BATTERY_ICON $'\uE894' #
|
||||||
HDD_ICON $'\uF0A0 ' #
|
DISK_ICON $'\uE1AE ' #
|
||||||
OK_ICON $'\u2713' # ✓
|
OK_ICON $'\u2713' # ✓
|
||||||
FAIL_ICON $'\u2718' # ✘
|
FAIL_ICON $'\u2718' # ✘
|
||||||
SYMFONY_ICON 'SF'
|
SYMFONY_ICON 'SF'
|
||||||
|
@ -98,7 +98,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
TEST_ICON $'\uF291' #
|
TEST_ICON $'\uF291' #
|
||||||
TODO_ICON $'\u2611' # ☑
|
TODO_ICON $'\u2611' # ☑
|
||||||
BATTERY_ICON $'\U1F50B' # 🔋
|
BATTERY_ICON $'\U1F50B' # 🔋
|
||||||
HDD_ICON $'\uF0A0 ' #
|
DISK_ICON $'\uF0A0 ' #
|
||||||
OK_ICON $'\u2713' # ✓
|
OK_ICON $'\u2713' # ✓
|
||||||
FAIL_ICON $'\u2718' # ✘
|
FAIL_ICON $'\u2718' # ✘
|
||||||
SYMFONY_ICON 'SF'
|
SYMFONY_ICON 'SF'
|
||||||
|
@ -158,7 +158,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
TEST_ICON ''
|
TEST_ICON ''
|
||||||
TODO_ICON $'\u2611' # ☑
|
TODO_ICON $'\u2611' # ☑
|
||||||
BATTERY_ICON $'\U1F50B' # 🔋
|
BATTERY_ICON $'\U1F50B' # 🔋
|
||||||
HDD_ICON $'HDD '
|
DISK_ICON $'hdd '
|
||||||
OK_ICON $'\u2713' # ✓
|
OK_ICON $'\u2713' # ✓
|
||||||
FAIL_ICON $'\u2718' # ✘
|
FAIL_ICON $'\u2718' # ✘
|
||||||
SYMFONY_ICON 'SF'
|
SYMFONY_ICON 'SF'
|
||||||
|
|
|
@ -338,10 +338,10 @@ prompt_background_jobs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Segment that indicates usage level of current partition.
|
# Segment that indicates usage level of current partition.
|
||||||
set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false
|
set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false
|
||||||
set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 90
|
set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90
|
||||||
set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 95
|
set_default POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL 95
|
||||||
prompt_hdd_usage() {
|
prompt_disk_usage() {
|
||||||
local current_state="unknown"
|
local current_state="unknown"
|
||||||
typeset -AH hdd_usage_forecolors
|
typeset -AH hdd_usage_forecolors
|
||||||
hdd_usage_forecolors=(
|
hdd_usage_forecolors=(
|
||||||
|
@ -356,25 +356,26 @@ prompt_hdd_usage() {
|
||||||
'critical' 'red'
|
'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'
|
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'
|
current_state='critical'
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then
|
if [[ "$POWERLEVEL9K_DISK_USAGE_ONLY_WARNING" == true ]]; then
|
||||||
|
current_state=''
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
current_state='normal'
|
current_state='normal'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local message="${level}%%"
|
local message="${disk_usage}%%"
|
||||||
|
|
||||||
# Draw the prompt_segment
|
# Draw the prompt_segment
|
||||||
if [[ -n $level ]]; then
|
if [[ -n $disk_usage ]]; then
|
||||||
"$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'HDD_ICON'
|
"$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue