-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmemory.sh
executable file
·30 lines (28 loc) · 1.06 KB
/
memory.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
source "utils.sh"
eutmux_memory(){
mem_total_and_used=$(free | grep Mem | sed -E -e's/\s+/ /g' | cut -d' ' -f2,3)
mem_total=$(echo $mem_total_and_used | cut -d' ' -f1)
mem_used=$(echo $mem_total_and_used | cut -d' ' -f2)
local mem_usage_percentage
mem_usage_percentage=$(percentage ${mem_used} ${mem_total})
is_mem_over_used=$(is_over_used ${mem_used} ${mem_total})
if [ $is_mem_over_used -eq $TRUE ];then
style=$(tmux show -gqv "@style")
fg_highlight=$(tmux show -gqv "@fg_highlight")
bg_highlight=$(tmux show -gqv "@bg_highlight")
_style="${style:-'nobold,nounderscore,noitalics'}"
if [ "${fg_highlight}" != "" ];then
_style="${_style},fg=${fg_highlight}"
fi
if [ "${bg_highlight}" != "" ];then
_style="${_style},bg=${bg_highlight}"
fi
mem_usage_percentage="#[${_style}] ${mem_usage_percentage} "
else
mem_usage_percentage=" ${mem_usage_percentage} "
fi
echo "${mem_usage_percentage}"
}
export eutmux_memory
eutmux_memory