-
Notifications
You must be signed in to change notification settings - Fork 10
/
ticker.tmux
executable file
·65 lines (54 loc) · 1.51 KB
/
ticker.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/scripts/helpers.sh"
ticker_commands=(
"#($CURRENT_DIR/scripts/dji.sh)"
"#($CURRENT_DIR/scripts/dji_change.sh)"
"#($CURRENT_DIR/scripts/nasdaq.sh)"
"#($CURRENT_DIR/scripts/nasdaq_change.sh)"
"#($CURRENT_DIR/scripts/sp100.sh)"
"#($CURRENT_DIR/scripts/sp100_change.sh)"
"#($CURRENT_DIR/scripts/sp500.sh)"
"#($CURRENT_DIR/scripts/sp500_change.sh)"
"#($CURRENT_DIR/scripts/stock.sh)"
"#($CURRENT_DIR/scripts/stock_change.sh)"
"#($CURRENT_DIR/scripts/crypto.sh)"
"#($CURRENT_DIR/scripts/crypto_change.sh)"
)
ticker_interpolation=(
"\#{ticker_dji}"
"\#{ticker_dji_change}"
"\#{ticker_nasdaq}"
"\#{ticker_nasdaq_change}"
"\#{ticker_sp100}"
"\#{ticker_sp100_change}"
"\#{ticker_sp500}"
"\#{ticker_sp500_change}"
"\#{ticker_stock}"
"\#{ticker_stock_change}"
"\#{ticker_crypto}"
"\#{ticker_crypto_change}"
)
set_tmux_options() {
local option="$1"
local value="$2"
tmux set-option -gp "$option" "$value"
}
do_interpolation() {
local interpolated="$1"
for ((i=0; i<${#ticker_commands[@]}; i++)); do
interpolated=${interpolated/${ticker_interpolation[$i]}/${ticker_commands[$i]}}
done
echo "$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