Keep tmux cursor colour on theme after apps reset it
Apps like nvim clear the per-pane cursor colour with OSC 112, which made tmux reset the outer terminal's cursor. Terminals that can't reload their config (foot) then restore the cursor colour from whatever theme was active at launch, leaving a mix of old and new cursor colours across panes. Set the global cursor-colour option as a fallback so cleared panes land on the current theme instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
38f516c430
commit
51bd33d7ab
@@ -56,17 +56,26 @@ theme_color() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sync_tmux_window_style() {
|
sync_tmux_window_style() {
|
||||||
local background foreground
|
local background foreground cursor
|
||||||
|
|
||||||
[[ -f $COLORS_TOML ]] || return
|
[[ -f $COLORS_TOML ]] || return
|
||||||
|
|
||||||
foreground=$(theme_color foreground)
|
foreground=$(theme_color foreground)
|
||||||
background=$(theme_color background)
|
background=$(theme_color background)
|
||||||
|
cursor=$(theme_color cursor)
|
||||||
|
|
||||||
[[ -n $foreground && -n $background ]] || return
|
[[ -n $foreground && -n $background ]] || return
|
||||||
|
|
||||||
tmux set-option -g window-style "fg=$foreground,bg=$background" 2>/dev/null || true
|
tmux set-option -g window-style "fg=$foreground,bg=$background" 2>/dev/null || true
|
||||||
tmux set-option -g window-active-style "fg=$foreground,bg=$background" 2>/dev/null || true
|
tmux set-option -g window-active-style "fg=$foreground,bg=$background" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Apps like nvim clear the per-pane cursor colour with OSC 112. Without a
|
||||||
|
# global fallback, tmux then resets the outer terminal's cursor, which in
|
||||||
|
# terminals that can't reload their config (foot) restores the colour from
|
||||||
|
# whatever theme was active when the terminal launched.
|
||||||
|
if [[ -n $cursor ]]; then
|
||||||
|
tmux set-option -g cursor-colour "$cursor" 2>/dev/null || true
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_tmux_pane_colors() {
|
sync_tmux_pane_colors() {
|
||||||
|
|||||||
Reference in New Issue
Block a user