forked from catppuccin/tmux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
catppuccin.tmux
executable file
Β·164 lines (138 loc) Β· 7.03 KB
/
catppuccin.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env bash
# Set path of script
PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# import
# shellcheck source=./builder/module_builder.sh
source "${PLUGIN_DIR}/builder/module_builder.sh"
# shellcheck source=./builder/window_builder.sh
source "${PLUGIN_DIR}/builder/window_builder.sh"
# shellcheck source=./builder/pane_builder.sh
source "${PLUGIN_DIR}/builder/pane_builder.sh"
# shellcheck source=./utils/tmux_utils.sh
source "${PLUGIN_DIR}/utils/tmux_utils.sh"
# shellcheck source=./utils/interpolate_utils.sh
source "${PLUGIN_DIR}/utils/interpolate_utils.sh"
# shellcheck source=./utils/module_utils.sh
source "${PLUGIN_DIR}/utils/module_utils.sh"
main() {
# Aggregate all commands in one array
local tmux_commands=()
# module directories
local custom_path modules_custom_path modules_status_path modules_window_path modules_pane_path
custom_path="$(get_tmux_option "@catppuccin_custom_plugin_dir" "${PLUGIN_DIR}/custom")"
modules_custom_path=$custom_path
modules_status_path=$PLUGIN_DIR/status
modules_window_path=$PLUGIN_DIR/window
modules_pane_path=$PLUGIN_DIR/pane
# load local theme
local theme
local color_interpolation=()
local color_values=()
local temp
theme="$(get_tmux_option "@catppuccin_flavour" "mocha")"
# NOTE: Pulling in the selected theme by the theme that's being set as local
# variables.
# https://github.com/dylanaraps/pure-sh-bible#parsing-a-keyval-file
# shellcheck source=./catppuccin-frappe.tmuxtheme
while IFS='=' read -r key val; do
# Skip over lines containing comments.
# (Lines starting with '#').
[ "${key##\#*}" ] || continue
# '$key' stores the key.
# '$val' stores the value.
eval "local $key"="$val"
# TODO: Find a better way to strip the quotes from `$val`
temp="${val%\"}"
temp="${temp#\"}"
color_interpolation+=("\#{$key}")
color_values+=("${temp}")
done <"${PLUGIN_DIR}/themes/catppuccin_${theme}.tmuxtheme"
# status general
local status_default status_justify status_background message_background
status_default=$(get_tmux_option "@catppuccin_status_default" "on")
# shellcheck disable=SC2121
set status "$status_default"
status_justify=$(get_tmux_option "@catppuccin_status_justify" "left")
set status-justify "$status_justify"
status_background=$(get_tmux_option "@catppuccin_status_background" "theme")
if [ "${status_background}" = "theme" ]; then
set status-bg "${thm_bg}"
message_background="${thm_gray}"
else
if [ "${status_background}" = "default" ]; then
set status-style bg=default
message_background="default"
else
message_background="$(do_color_interpolation "$status_background")"
set status-bg "${message_background}"
fi
fi
set status-left-length "100"
set status-right-length "100"
# messages
set message-style "fg=${thm_cyan},bg=${message_background},align=centre"
set message-command-style "fg=${thm_cyan},bg=${message_background},align=centre"
# menu
local menu_style menu_selected_style menu_border_style
menu_style=$(get_interpolated_tmux_option "@catppuccin_menu_style" "default")
menu_selected_style=$(get_interpolated_tmux_option "@catppuccin_menu_selected_style" "fg=${thm_gray},bg=${thm_yellow}")
menu_border_style=$(get_interpolated_tmux_option "@catppuccin_menu_border_style" "default")
set menu-style "$menu_style"
set menu-selected-style "$menu_selected_style"
set menu-border-style "$menu_border_style"
# panes
local pane_border_status pane_border_style \
pane_active_border_style pane_left_separator pane_middle_separator \
pane_right_separator pane_number_position pane_format
pane_status_enable=$(get_tmux_option "@catppuccin_pane_status_enabled" "no") # yes
pane_border_status=$(get_tmux_option "@catppuccin_pane_border_status" "off") # bottom
pane_border_style=$(
get_interpolated_tmux_option "@catppuccin_pane_border_style" "fg=${thm_gray}"
)
pane_active_border_style=$(
get_interpolated_tmux_option "@catppuccin_pane_active_border_style" \
"#{?pane_in_mode,fg=${thm_yellow},#{?pane_synchronized,fg=${thm_magenta},fg=${thm_orange}}}"
)
pane_left_separator=$(get_tmux_option "@catppuccin_pane_left_separator" "β")
pane_middle_separator=$(get_tmux_option "@catppuccin_pane_middle_separator" "β")
pane_right_separator=$(get_tmux_option "@catppuccin_pane_right_separator" "β")
pane_number_position=$(get_tmux_option "@catppuccin_pane_number_position" "left") # right, left
pane_format=$(load_modules "pane_default_format" "$modules_custom_path" "$modules_pane_path")
setw pane-border-status "$pane_border_status"
setw pane-active-border-style "$pane_active_border_style"
setw pane-border-style "$pane_border_style"
setw pane-border-format "$(do_color_interpolation "$pane_format")"
# window
local window_status_separator window_left_separator window_right_separator \
window_middle_separator window_number_position window_status_enable \
window_format window_current_format
window_status_separator=$(get_interpolated_tmux_option "@catppuccin_window_separator" "")
setw window-status-separator "$window_status_separator"
window_left_separator=$(get_tmux_option "@catppuccin_window_left_separator" "β")
window_right_separator=$(get_tmux_option "@catppuccin_window_right_separator" "β")
window_middle_separator=$(get_tmux_option "@catppuccin_window_middle_separator" "β ")
window_number_position=$(get_tmux_option "@catppuccin_window_number_position" "left") # right, left
window_status_enable=$(get_tmux_option "@catppuccin_window_status_enable" "no") # right, left
window_format=$(load_modules "window_default_format" "$modules_custom_path" "$modules_window_path")
setw window-status-format "$(do_color_interpolation "$window_format")"
window_current_format=$(load_modules "window_current_format" "$modules_custom_path" "$modules_window_path")
setw window-status-current-format "$(do_color_interpolation "$window_current_format")"
# status module
local status_left_separator status_right_separator status_connect_separator \
status_fill status_modules_left status_modules_right
status_left_separator=$(get_tmux_option "@catppuccin_status_left_separator" "ξΆ")
status_right_separator=$(get_tmux_option "@catppuccin_status_right_separator" "β")
status_connect_separator=$(get_tmux_option "@catppuccin_status_connect_separator" "yes")
status_fill=$(get_tmux_option "@catppuccin_status_fill" "icon")
status_modules_left=$(get_tmux_option "@catppuccin_status_modules_left" "")
loaded_modules_left=$(load_modules "$status_modules_left" "$modules_custom_path" "$modules_status_path")
set status-left "$(do_color_interpolation "$loaded_modules_left")"
status_modules_right=$(get_tmux_option "@catppuccin_status_modules_right" "application session")
loaded_modules_right=$(load_modules "$status_modules_right" "$modules_custom_path" "$modules_status_path")
set status-right "$(do_color_interpolation "$loaded_modules_right")"
# modes
setw clock-mode-colour "${thm_blue}"
setw mode-style "fg=${thm_pink} bg=${thm_black4} bold"
tmux "${tmux_commands[@]}"
}
main "$@"