forked from catppuccin/tmux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
catppuccin.tmux
executable file
·175 lines (131 loc) · 5.86 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
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env bash
PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
get_tmux_option() {
local option value default
option="$1"
default="$2"
value="$(tmux show-option -gqv "$option")"
if [ -n "$value" ]; then
echo "$value"
else
echo "$default"
fi
}
set() {
local option=$1
local value=$2
tmux_commands+=(set-option -gq "$option" "$value" ";")
}
setw() {
local option=$1
local value=$2
tmux_commands+=(set-window-option -gq "$option" "$value" ";")
}
main() {
local theme
theme="$(get_tmux_option "@catppuccin_flavour" "mocha")"
# Aggregate all commands in one array
local tmux_commands=()
# NOTE: Pulling in the selected theme by the theme that's being set as local
# variables.
# shellcheck source=catppuccin-frappe.tmuxtheme
source /dev/stdin <<<"$(sed -e "/^[^#].*=/s/^/local /" "${PLUGIN_DIR}/catppuccin-${theme}.tmuxtheme")"
# status
set status "on"
set status-bg "${thm_bg}"
set status-justify "left"
set status-left-length "100"
set status-right-length "100"
# messages
set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre"
set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre"
# panes
set pane-border-style "fg=${thm_gray}"
set pane-active-border-style "fg=${thm_blue}"
# windows
setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none"
setw window-status-separator ""
setw window-status-style "fg=${thm_fg},bg=${thm_bg},none"
# --------=== Statusline
# NOTE: Checking for the value of @catppuccin_window_tabs_enabled
local wt_enabled
wt_enabled="$(get_tmux_option "@catppuccin_window_tabs_enabled" "off")"
readonly wt_enabled
local right_separator
right_separator="$(get_tmux_option "@catppuccin_right_separator" "")"
readonly right_separator
local left_separator
left_separator="$(get_tmux_option "@catppuccin_left_separator" "")"
readonly left_separator
local user
user="$(get_tmux_option "@catppuccin_user" "off")"
readonly user
local host
host="$(get_tmux_option "@catppuccin_host" "off")"
readonly host
local date_time
date_time="$(get_tmux_option "@catppuccin_date_time" "off")"
readonly date_time
local k8_cluster
k8_cluster="$(get_tmux_option "@catppuccin_k8_cluster" "off")"
readonly k8_cluster
# These variables are the defaults so that the setw and set calls are easier to parse.
local show_directory
readonly show_directory="#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]$right_separator#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} #{?client_prefix,#[fg=$thm_red]"
local show_window
readonly show_window="#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]$right_separator#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #[fg=$thm_fg,bg=$thm_gray] #W #{?client_prefix,#[fg=$thm_red]"
local show_session
readonly show_session="#[fg=$thm_green]}#[bg=$thm_gray]$right_separator#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg] #[fg=$thm_fg,bg=$thm_gray] #S "
local show_directory_in_window_status
readonly show_directory_in_window_status="#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} "
local show_directory_in_window_status_current
readonly show_directory_in_window_status_current="#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} "
local show_window_name_in_window_status
readonly show_window_name_in_window_status="#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #W "
local show_window_name_in_window_status_current
readonly show_window_name_in_window_status_current="#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #W "
local show_user
readonly show_user="#[fg=$thm_blue,bg=$thm_gray]$right_separator#[fg=$thm_bg,bg=$thm_blue] #[fg=$thm_fg,bg=$thm_gray] #(whoami) "
local show_host
readonly show_host="#[fg=$thm_blue,bg=$thm_gray]$right_separator#[fg=$thm_bg,bg=$thm_blue] #[fg=$thm_fg,bg=$thm_gray] #H "
local show_date_time
readonly show_date_time="#[fg=$thm_blue,bg=$thm_gray]$right_separator#[fg=$thm_bg,bg=$thm_blue] #[fg=$thm_fg,bg=$thm_gray] $date_time "
local show_k8_cluster
readonly show_k8_cluster="#[fg=$thm_blue,bg=$thm_gray]$right_separator#[fg=$thm_bg,bg=$thm_blue]ﴱ #[fg=$thm_fg,bg=$thm_gray] #(kubectl config current-context) "
# Right column 1 by default shows the Window name.
local right_column1=$show_directory # changed to directory and left column to session name
# Right column 2 by default shows the current Session name.
local right_column2=$show_session
# Window status by default shows the current directory basename.
local window_status_format=$show_window_name_in_window_status
local window_status_current_format=$show_window_name_in_window_status_current
# NOTE: With the @catppuccin_window_tabs_enabled set to on, we're going to
# update the right_column1 and the window_status_* variables.
if [[ "${wt_enabled}" == "on" ]]; then
right_column1=$show_directory
window_status_format=$show_window_in_window_status
window_status_current_format=$show_window_in_window_status_current
fi
if [[ "${user}" == "on" ]]; then
right_column2=$right_column2$show_user
fi
if [[ "${host}" == "on" ]]; then
right_column2=$right_column2$show_host
fi
if [[ "${date_time}" != "off" ]]; then
right_column2=$right_column2$show_date_time
fi
if [[ "${k8_cluster}" != "off" && -n $(kubectl config current-context) ]]; then
right_column2=$show_k8_cluster$right_column2
fi
set status-left ""
set status-right "${right_column1},${right_column2}"
setw window-status-format "${window_status_format}"
setw window-status-current-format "${window_status_current_format}"
# --------=== Modes
#
setw clock-mode-colour "${thm_blue}"
setw mode-style "fg=${thm_pink} bg=${thm_black4} bold"
tmux "${tmux_commands[@]}"
}
main "$@"