-
Notifications
You must be signed in to change notification settings - Fork 0
/
mem.tmux
executable file
·36 lines (29 loc) · 940 Bytes
/
mem.tmux
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
31
32
33
34
35
36
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/scripts/helpers.sh"
mem_percentage="#($CURRENT_DIR/scripts/mem_percentage.sh)"
mem_icon="#($CURRENT_DIR/scripts/mem_icon.sh)"
mem_percentage_interpolation="\#{mem_percentage}"
mem_icon_interpolation="\#{mem_icon}"
set_tmux_option() {
local option=$1
local value=$2
tmux set-option -gq "$option" "$value"
}
do_interpolation() {
local string=$1
local percentage_interpolated=${string/$mem_percentage_interpolation/$mem_percentage}
local all_interpolated=${percentage_interpolated/$mem_icon_interpolation/$mem_icon}
echo $all_interpolated
}
update_tmux_option() {
local option=$1
local option_value=$(get_tmux_option "$option")
local new_option_value=$(do_interpolation "$option_value")
set_tmux_option "$option" "$new_option_value"
}
main() {
update_tmux_option "status-right"
update_tmux_option "status-left"
}
main