|
1 | 1 | #!/usr/bin/env bash |
2 | | -# Sync tmux theme with macOS system appearance. |
| 2 | +# Sync tmux theme with macOS system appearance: Catppuccin Latte / Mocha. |
3 | 3 | # 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. |
4 | 8 |
|
5 | 9 | 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" |
15 | 18 | 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" |
25 | 27 | 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