-
Notifications
You must be signed in to change notification settings - Fork 0
/
kubectl.tmux
executable file
·43 lines (35 loc) · 995 Bytes
/
kubectl.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
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
kubectl_value="#($CURRENT_DIR/scripts/kubectl.sh)"
kubectl_context_interpolation_string="\#{kubectl_context}"
get_tmux_option() {
local option=$1
local default_value=$2
local option_value=$(tmux show-option -gqv "$option")
if [ -z "$option_value" ]; then
echo "$default_value"
else
echo "$option_value"
fi
}
set_tmux_option() {
local option="$1"
local value="$2"
tmux set-option -gq "$option" "$value"
}
do_interpolation() {
local string="$1"
local interpolated="${string/$kubectl_context_interpolation_string/$kubectl_value}"
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-left"
update_tmux_option "status-right"
}
main