Skip to content

Commit 5faec7e

Browse files
committed
feat(tmux): theme menus, messages and copy mode with Catppuccin
tmux defaults mode-style, message-style and menu-selected-style to bg=yellow, so every menu, prompt and copy-mode selection flashed a stray orange on an otherwise themed setup. Point them, plus the copy-mode match styles, the Prefix+t clock and the Prefix+q pane numbers, at the same Latte/Mocha palettes the status bar already uses. Restructure into per-mode palette variables rather than two near-identical blocks of set-option calls, since this roughly triples the number of options being set. This script runs on every status redraw, so guard on @appearance and bail out unless the system appearance actually flipped — steady state is now one show-options instead of twenty-odd set-options.
1 parent 612d5b1 commit 5faec7e

1 file changed

Lines changed: 60 additions & 19 deletions

File tree

‎.tmux/theme-sync.sh‎

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,66 @@
11
#!/usr/bin/env bash
2-
# Sync tmux theme with macOS system appearance.
2+
# Sync tmux theme with macOS system appearance: Catppuccin Latte / Mocha.
33
# Called on tmux startup and re-evaluated via #() in status-format.
4+
#
5+
# Two deliberate exceptions to the palettes: the accent stays Latte's sky in
6+
# both modes (it reads on either background, so the active window is the same
7+
# color all day), and @time_fg stays Latte's overlay1 for the same reason.
48

59
if defaults read -g AppleInterfaceStyle 2>/dev/null | grep -q Dark; then
6-
# Dark: readable fg on dark bg, but reuse Latte's saturated accents
7-
tmux set-option -gq status-style "bg=default,fg=white"
8-
tmux set-option -gq pane-border-style "fg=#191923"
9-
tmux set-option -gq pane-active-border-style "fg=#04a5e5"
10-
tmux set-option -gq @active_fg "#04a5e5"
11-
tmux set-option -gq @time_fg "#8c8fa1"
12-
tmux set-option -gq @clock_fg "#a6adc8"
13-
tmux set-option -gq @load_warn_fg "#f9e2af"
14-
tmux set-option -gq @load_crit_fg "#f38ba8"
10+
mode=dark
11+
# Mocha
12+
surface0="#313244"; surface1="#45475a"
13+
text="#cdd6f4"; status_fg="white"
14+
border="#191923"
15+
clock="#a6adc8"
16+
warn="#f9e2af"; crit="#f38ba8"; peach="#fab387"
17+
mark="#cba6f7"; mark_fg="#11111b"
1518
else
16-
# Catppuccin Latte
17-
tmux set-option -gq status-style "bg=default,fg=#4c4f69"
18-
tmux set-option -gq pane-border-style "fg=#ccd0da"
19-
tmux set-option -gq pane-active-border-style "fg=#04a5e5"
20-
tmux set-option -gq @active_fg "#04a5e5"
21-
tmux set-option -gq @time_fg "#8c8fa1"
22-
tmux set-option -gq @clock_fg "#6c6f85"
23-
tmux set-option -gq @load_warn_fg "#df8e1d"
24-
tmux set-option -gq @load_crit_fg "#d20f39"
19+
mode=light
20+
# Latte
21+
surface0="#ccd0da"; surface1="#bcc0cc"
22+
text="#4c4f69"; status_fg="#4c4f69"
23+
border="#ccd0da"
24+
clock="#6c6f85"
25+
warn="#df8e1d"; crit="#d20f39"; peach="#fe640b"
26+
mark="#8839ef"; mark_fg="#eff1f5"
2527
fi
28+
29+
# This script runs on every status redraw. Re-applying ~20 options each time is
30+
# pure waste, so bail out unless the appearance actually flipped. Editing the
31+
# colors below? Run `tmux set -gu @appearance` first to force a re-apply.
32+
[ "$(tmux show-options -gqv @appearance)" = "$mode" ] && exit 0
33+
tmux set-option -gq @appearance "$mode"
34+
35+
accent="#04a5e5" # Latte sky, in both modes
36+
contrast="#11111b" # readable on the accent and on every highlight below
37+
38+
# Status bar and panes
39+
tmux set-option -gq status-style "bg=default,fg=$status_fg"
40+
tmux set-option -gq pane-border-style "fg=$border"
41+
tmux set-option -gq pane-active-border-style "fg=$accent"
42+
tmux set-option -gq @active_fg "$accent"
43+
tmux set-option -gq @time_fg "#8c8fa1"
44+
tmux set-option -gq @clock_fg "$clock"
45+
tmux set-option -gq @load_warn_fg "$warn"
46+
tmux set-option -gq @load_crit_fg "$crit"
47+
48+
# Menus, messages and popups. These default to bg=yellow, which is the stray
49+
# orange that shows up in every menu and prompt on an otherwise themed setup.
50+
tmux set-option -gq mode-style "bg=$accent,fg=$contrast"
51+
tmux set-option -gq message-style "bg=$surface0,fg=$text"
52+
tmux set-option -gq message-command-style "bg=$surface0,fg=$peach"
53+
tmux set-option -gq menu-style "bg=$surface0,fg=$text"
54+
tmux set-option -gq menu-selected-style "bg=$accent,fg=$contrast"
55+
tmux set-option -gq menu-border-style "fg=$surface1"
56+
tmux set-option -gq popup-border-style "fg=$surface1"
57+
58+
# Copy mode: every match subdued, the current one loud, marks distinct from both.
59+
tmux set-option -gq copy-mode-match-style "bg=$warn,fg=$contrast"
60+
tmux set-option -gq copy-mode-current-match-style "bg=$peach,fg=$contrast"
61+
tmux set-option -gq copy-mode-mark-style "bg=$mark,fg=$mark_fg"
62+
63+
# Prefix+t clock and Prefix+q pane numbers
64+
tmux set-option -gq clock-mode-colour "$accent"
65+
tmux set-option -gq display-panes-colour "#8c8fa1"
66+
tmux set-option -gq display-panes-active-colour "$accent"

0 commit comments

Comments
 (0)