forked from tmux-plugins/tmux-net-speed
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnet_speed.tmux
executable file
·39 lines (31 loc) · 1.04 KB
/
net_speed.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
37
38
39
#!/bin/bash -
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/scripts/helpers.sh"
download_speed="#($CURRENT_DIR/scripts/download_speed.sh)"
net_speed="#($CURRENT_DIR/scripts/net_speed.sh)"
upload_speed="#($CURRENT_DIR/scripts/upload_speed.sh)"
ip="#($CURRENT_DIR/scripts/ip.sh)"
download_interpolation="\#{download_speed}"
net_interpolation="\#{net_speed}"
upload_interpolation="\#{upload_speed}"
ip_interpolation="\#{ip}"
do_interpolation() {
local input=$1
local result=""
result=${input/$download_interpolation/$download_speed}
result=${result/$net_interpolation/$net_speed}
result=${result/$upload_interpolation/$upload_speed}
result=${result/$ip_interpolation/$ip}
echo $result
}
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