aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-07-29 11:07:42 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-07-29 11:07:42 +0300
commit7f6e74f0126d8bd57070944c5595f9c30db8aae5 (patch)
tree9d15b1633dac09c9c4defc48d696abe13ff8a65c /internal/p10k.zsh
parentd963f10db9be099c603d3ae29575664529b8bc37 (diff)
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.
Diffstat (limited to 'internal/p10k.zsh')
-rwxr-xr-xinternal/p10k.zsh6
1 files changed, 4 insertions, 2 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 76ad8f61..86d2c242 100755
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -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