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

Don't show ram prompt if /proc/meminfo lists not-a-number for MemAvailable.

I've never encountered the case where this commit makes a difference
but it's possible that #136 will get fixed.
This commit is contained in:
romkatv 2019-07-29 10:07:42 +02:00
parent d963f10db9
commit 7f6e74f012

View file

@ -1956,8 +1956,10 @@ prompt_ram() {
free_bytes=${${(A)=stat}[4]}
;;
*)
local stat && stat=$(grep -F MemAvailable /proc/meminfo 2>/dev/null) || return
free_bytes=$(( ${${(A)=stat}[2]} * 1024 ))
[[ -r /proc/meminfo ]] || return
local stat && stat="$(</proc/meminfo)" || return
[[ $stat == (#b)*'MemAvailable:'[[:space:]]#(<->)* ]] || return
free_bytes=$(( $match[1] * 1024 ))
;;
esac