-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_theme_tmux
executable file
·127 lines (102 loc) · 2.78 KB
/
change_theme_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash
# Change tmux theme.
# $1 - theme
# Supported themes are
# latte
# macchiato
# nord
# onedark
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# Source helper script.
source "$DIR/lib/helper.sh"
if [ -z "$1" ]; then
echoerr "Missing argument"
exit 1
fi
set() {
local option=$1
local value=$2
tmux set-option -gq "$option" "$value"
}
setw() {
local option=$1
local value=$2
tmux set-window-option -gq "$option" "$value"
}
set_theme() {
set status-style "bg=$status_bg,fg=$status_fg"
set status-left-style "bg=$status_left_bg,fg=$status_left_fg"
set status-right-style "bg=$status_right_bg,fg=$status_right_fg"
setw window-status-style "bg=$window_bg,fg=$window_fg"
setw window-status-current-style "bg=$window_current_bg,fg=$window_current_fg"
set pane-border-style "bg=$pane_border_bg,fg=$pane_border_fg"
set pane-active-border-style "bg=$pane_active_border_bg,fg=$pane_active_border_fg"
}
set_var_latte() {
# Colors from https://github.com/catppuccin/catppuccin
status_left_bg="#1e66f5"
status_left_fg="#dce0e8"
status_right_bg="#dd7878"
status_right_fg="#dce0e8"
window_current_bg="#e64553"
window_current_fg="#dce0e8"
pane_border_fg="#6c6f85"
pane_active_border_fg="#7287fd"
}
set_var_macchiato() {
# Colors from https://github.com/catppuccin/catppuccin
status_left_bg="#c6a0f6"
status_left_fg="#24273a"
status_right_bg="#f0c6c6"
status_right_fg="#24273a"
window_current_fg="#24273a"
window_current_bg="#ee99a0"
pane_border_fg="#5b6078"
pane_active_border_fg="#b7bdf8"
}
set_var_nord() {
# Colors from https://www.nordtheme.com
status_left_bg="#81a1c1"
status_left_fg="#2e3440"
status_right_bg="#88c0d0"
status_right_fg="#2e3440"
window_current_bg="#88c0d0"
window_current_fg="#2e3440"
pane_border_fg="#4c566a"
pane_active_border_fg="#88c0d0"
}
set_var_onedark() {
# Colors from https://github.com/Binaryify/OneDark-Pro
status_fg="#282c34"
status_bg="#8cc265"
pane_border_fg="#4f5666"
pane_active_border_fg="#8cc265"
}
change_line() {
grep -q "$2" "$3" && return
sed -i "s|$1|$2|g" "$3" || echo "Cannot modify $3"
}
theme="$1"
func=set_var_"$theme"
if ! [[ $(type -t "$func") == function ]]; then
echoerr "Invalid theme $theme"
exit 1
fi
def="default"
status_bg="$def"
status_fg="$def"
status_left_bg="$def"
status_left_fg="$def"
status_right_bg="$def"
status_right_fg="$def"
window_bg="$def"
window_fg="$def"
window_current_bg="$def"
window_current_fg="$def"
pane_border_bg="$def"
pane_border_fg="$def"
pane_active_border_bg="$def"
pane_active_border_fg="$def"
"$func"
set_theme
change_line "run \"change_theme_tmux .*\"" "run \"change_theme_tmux $theme\"" "$XDG_CONFIG_HOME/tmux/tmux.conf"