1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-12 08:10:07 +00:00

Change ram segment to take an optional root prefix for testability

This commit is contained in:
Dominik Ritter 2018-07-18 22:24:25 +02:00
parent 1e71d452e1
commit e99c7549fb

View file

@ -1241,6 +1241,7 @@ prompt_php_version() {
################################################################ ################################################################
# Segment to display free RAM and used Swap # Segment to display free RAM and used Swap
prompt_ram() { prompt_ram() {
local ROOT_PREFIX="${4}"
local base='' local base=''
local ramfree=0 local ramfree=0
if [[ "$OS" == "OSX" ]]; then if [[ "$OS" == "OSX" ]]; then
@ -1252,9 +1253,9 @@ prompt_ram() {
ramfree=$(( ramfree * 4096 )) ramfree=$(( ramfree * 4096 ))
else else
if [[ "$OS" == "BSD" ]]; then if [[ "$OS" == "BSD" ]]; then
ramfree=$(grep 'avail memory' /var/run/dmesg.boot | awk '{print $4}') ramfree=$(grep 'avail memory' ${ROOT_PREFIX}/var/run/dmesg.boot | awk '{print $4}')
else else
ramfree=$(grep -o -E "MemAvailable:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") ramfree=$(grep -o -E "MemAvailable:\s+[0-9]+" ${ROOT_PREFIX}/proc/meminfo | grep -o -E "[0-9]+")
base='K' base='K'
fi fi
fi fi