From 08d3e1e8a7d5e76991769e78b9ab470643881c49 Mon Sep 17 00:00:00 2001 From: David Chen Date: Sun, 5 Oct 2025 10:05:53 -0700 Subject: [PATCH] tmux configurable theme color part 2 --- .tmux.conf | 11 ++++++----- tmux/scripts/update_theme_color.sh | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100755 tmux/scripts/update_theme_color.sh diff --git a/.tmux.conf b/.tmux.conf index 7426e15..a79df38 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -228,7 +228,7 @@ bind E run-shell "~/.config/tmux/scripts/layout_builder.sh down" # -- toggle_syn_input bind C-g if-shell '[[ $(tmux showw synchronize-panes | cut -d\ -f2) == "on" ]]' \ -'setw synchronize-panes off; set -g pane-border-style fg=magenta' \ +'setw synchronize-panes off; set -g pane-border-style fg=#{?#{!=:#{environ:TMUX_THEME_COLOR},},#{environ:TMUX_THEME_COLOR},#b294bb}' \ 'setw synchronize-panes on; set -g pane-border-style fg=red' # -- toggle_status @@ -236,10 +236,11 @@ bind C-g if-shell '[[ $(tmux showw synchronize-panes | cut -d\ -f2) == "on" ]]' # -- theme # panes +run-shell "~/.config/tmux/scripts/update_theme_color.sh" setw -g pane-border-status top -set -g pane-active-border-style fg=brightblue +set -g pane-active-border-style fg=#b294bb set -g pane-border-style fg=colour244 -setw -g pane-border-format '#{?pane_active, #[fg=#{?#{!=:#{environ:TMUX_THEME_COLOR},},#{environ:TMUX_THEME_COLOR},#b294bb}]#[bg=#{?#{!=:#{environ:TMUX_THEME_COLOR},},#{environ:TMUX_THEME_COLOR},#b294bb}]#[fg=#1d1f21]#[bold] #{?window_zoomed_flag,⛶ ,} #(~/.config/tmux/scripts/pane_starship_title.sh #{pane_pid} #{pane_width} "#{pane_current_path}" "#{pane_current_command}") #[bg=default]#[fg=#{?#{!=:#{environ:TMUX_THEME_COLOR},},#{environ:TMUX_THEME_COLOR},#b294bb}]#[default], #[fg=colour244]#[bg=colour244]#[fg=#1d1f21] #{?window_zoomed_flag,⛶ ,} #(~/.config/tmux/scripts/pane_starship_title.sh #{pane_pid} #{pane_width} "#{pane_current_path}" "#{pane_current_command}") #[bg=default]#[fg=colour244]#[default] }' +setw -g pane-border-format '#{?pane_active, #[fg=#{@theme_color}]#[bg=#{@theme_color}]#[fg=#1d1f21]#[bold] #{?window_zoomed_flag,⛶ ,} #(~/.config/tmux/scripts/pane_starship_title.sh #{pane_pid} #{pane_width} "#{pane_current_path}" "#{pane_current_command}") #[bg=default]#[fg=#{@theme_color}]#[default], #[fg=colour244]#[bg=colour244]#[fg=#1d1f21] #{?window_zoomed_flag,⛶ ,} #(~/.config/tmux/scripts/pane_starship_title.sh #{pane_pid} #{pane_width} "#{pane_current_path}" "#{pane_current_command}") #[bg=default]#[fg=colour244]#[default] }' #set -g pane-active-border-style fg=brightblue #set -g pane-border-style fg=magenta @@ -257,8 +258,8 @@ set -g status-bg black #set -g status-left '#[fg=brightyellow] #{?client_prefix,⌨ , } #[fg=magenta,bold] %Y-%m-%d %H:%M ' #set -g status-right '#(rainbarf --battery --remaining --bolt --tmux --rgb)' #set -g status-left "#[fg=magenta,bold] %Y-%m-%d %H:%M | #[fg=brightblue]#(curl icanhazip.com) #(ifconfig en0 | grep 'inet ' | awk '{print \"en0 \" $2}') #(ifconfig en1 | grep 'inet ' | awk '{print \"en1 \" $2}') #(ifconfig en3 | grep 'inet ' | awk '{print \"en3 \" $2}') #(ifconfig tun0 | grep 'inet ' | awk '{print \"vpn \" $2}') " -setw -g window-status-format '#[fg=brightblue] #W ' -setw -g window-status-current-format '#[fg=#{?#{!=:#{environ:TMUX_THEME_COLOR},},#{environ:TMUX_THEME_COLOR},#b294bb},bold] #W ' +setw -g window-status-format '#[fg=#c5c8c6] #W ' +setw -g window-status-current-format '#[fg=#{@theme_color},bold] #W ' setw -g window-status-activity-style bg=black setw -g window-status-bell-style bg=black #set-window-option -g window-status-current-format "#[fg=colour235, bg=colour27]⮀#[fg=colour255, bg=colour27] #I ⮁ #W #[fg=colour27, bg=colour235]⮀" diff --git a/tmux/scripts/update_theme_color.sh b/tmux/scripts/update_theme_color.sh new file mode 100755 index 0000000..89d21ef --- /dev/null +++ b/tmux/scripts/update_theme_color.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Determine theme color from tmux environments with fallback +# Prefer session env, then global env, else default. +theme_line=$(tmux show-environment TMUX_THEME_COLOR 2>/dev/null || true) +if [[ "$theme_line" == TMUX_THEME_COLOR=* ]]; then + theme="${theme_line#TMUX_THEME_COLOR=}" +else + theme_line=$(tmux show-environment -g TMUX_THEME_COLOR 2>/dev/null || true) + if [[ "$theme_line" == TMUX_THEME_COLOR=* ]]; then + theme="${theme_line#TMUX_THEME_COLOR=}" + else + theme="#b294bb" + fi +fi + +# Cache as a user option and apply to border style +tmux set -g @theme_color "$theme" +tmux set -g pane-active-border-style "fg=$theme" + +exit 0