mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2026-09-29 00:04:36 +00:00
Change swap segment to take an optional root prefix for testability
This commit is contained in:
@@ -1422,6 +1422,7 @@ prompt_status() {
|
|||||||
################################################################
|
################################################################
|
||||||
# Segment to display Swap information
|
# Segment to display Swap information
|
||||||
prompt_swap() {
|
prompt_swap() {
|
||||||
|
local ROOT_PREFIX="${4}"
|
||||||
local swap_used=0
|
local swap_used=0
|
||||||
local base=''
|
local base=''
|
||||||
|
|
||||||
@@ -1436,8 +1437,8 @@ prompt_swap() {
|
|||||||
|
|
||||||
base=$(echo "$raw_swap_used" | grep -o "[A-Z]*$")
|
base=$(echo "$raw_swap_used" | grep -o "[A-Z]*$")
|
||||||
else
|
else
|
||||||
swap_total=$(grep -o -E "SwapTotal:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
swap_total=$(grep -o -E "SwapTotal:\s+[0-9]+" ${ROOT_PREFIX}/proc/meminfo | grep -o -E "[0-9]+")
|
||||||
swap_free=$(grep -o -E "SwapFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
swap_free=$(grep -o -E "SwapFree:\s+[0-9]+" ${ROOT_PREFIX}/proc/meminfo | grep -o -E "[0-9]+")
|
||||||
swap_used=$(( swap_total - swap_free ))
|
swap_used=$(( swap_total - swap_free ))
|
||||||
base='K'
|
base='K'
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user