Files
omarchycn/config/tmux/tmux.conf
T
David Heinemeier HanssonandClaude Opus 5 e880cf77cc Alert on tmux output while its terminal is unfocused
tmux only raises an activity flag for windows that are not currently
selected, so a long-running command in the window you left selected --
the common case, since you switch away by moving your Hyprland focus
elsewhere rather than by selecting another tmux window -- finished
silently and the indicator never lit.

Windows now also count as waiting when they are selected in an attached
client, every client showing them is unfocused, and their window_activity
is newer than an @omarchy_unfocused_activity watermark. The watermark is
stamped by a new `track` subcommand wired to client-focus-in/out and the
existing select-window hooks, so it records where attention last was.
The hooks pass #{window_id} and #{window_activity} as arguments, which
tmux expands when the hook fires; run-shell -b would otherwise let output
arriving during the handoff be swallowed by the new watermark. The focus
hooks take index 100 to leave a user's own bindings alone.

That state has no hook of its own, so it needs polling to be noticed.
The probe therefore moves out of the indicator and into a service plugin,
alongside nightlight and battery. A bar surface exists per monitor and
each one instantiates every indicator twice, once per block, so a timer
on the indicator meant a shell-out per instance per tick -- four probe
processes every three seconds on a two-monitor machine, forever. One
service polls for the whole shell instead.

Sharing the state also fixes what per-instance polling would have papered
over: each indicator used to own its own count, so a timer-driven update
only refreshed the bar it ran on and left the other monitors stale.
Refreshes still arrive over the existing indicator broadcast, which now
coalesces into a single run no matter how many bars relay it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018CC9kSQv8ZEogaxDoeKBzL
2026-07-25 07:19:02 -07:00

116 lines
4.8 KiB
Bash

# Prefix
set -g prefix C-Space
set -g prefix2 C-b
bind -N "Send prefix" C-Space send-prefix
# Config and help
bind -N "Reload configuration" q source-file ~/.config/tmux/tmux.conf \; display "Configuration reloaded"
bind -N "Show Tmux keybindings" ? display-popup -E -w 80% -h 70% -T "Tmux keybindings" "omarchy-menu-tmux-keybindings --print | less -R"
# Vi mode for copy
setw -g mode-keys vi
bind -N "Begin selection" -T copy-mode-vi v send -X begin-selection
bind -N "Copy selection" -T copy-mode-vi y send -X copy-selection-and-cancel
# Pane Controls
bind -N "Split pane vertically" -n M-Enter split-window -v -c "#{pane_current_path}"
bind -N "Split pane horizontally" -n M-S-Enter split-window -h -c "#{pane_current_path}"
bind -N "Kill pane" -n M-Escape kill-pane
bind -N "Split pane vertically" h split-window -v -c "#{pane_current_path}"
bind -N "Split pane horizontally" v split-window -h -c "#{pane_current_path}"
bind -N "Kill pane" x kill-pane
bind -N "Focus pane left" -n C-M-Left select-pane -L
bind -N "Focus pane right" -n C-M-Right select-pane -R
bind -N "Focus pane up" -n C-M-Up select-pane -U
bind -N "Focus pane down" -n C-M-Down select-pane -D
bind -N "Resize pane left" -n C-M-S-Left resize-pane -L 5
bind -N "Resize pane down" -n C-M-S-Down resize-pane -D 5
bind -N "Resize pane up" -n C-M-S-Up resize-pane -U 5
bind -N "Resize pane right" -n C-M-S-Right resize-pane -R 5
# Window navigation
bind -N "Rename window" r command-prompt -I "#W" "rename-window -- '%%'"
bind -N "Create window" c new-window -c "#{pane_current_path}"
bind -N "Kill window" k kill-window
bind -N "Switch to window 1" -n M-1 select-window -t 1
bind -N "Switch to window 2" -n M-2 select-window -t 2
bind -N "Switch to window 3" -n M-3 select-window -t 3
bind -N "Switch to window 4" -n M-4 select-window -t 4
bind -N "Switch to window 5" -n M-5 select-window -t 5
bind -N "Switch to window 6" -n M-6 select-window -t 6
bind -N "Switch to window 7" -n M-7 select-window -t 7
bind -N "Switch to window 8" -n M-8 select-window -t 8
bind -N "Switch to window 9" -n M-9 select-window -t 9
bind -N "Previous window" -n M-Left select-window -t -1
bind -N "Next window" -n M-Right select-window -t +1
bind -N "Move window left" -n M-S-Left swap-window -t -1 \; select-window -t -1
bind -N "Move window right" -n M-S-Right swap-window -t +1 \; select-window -t +1
# Session controls
bind -N "Rename session" R command-prompt -I "#S" "rename-session -- '%%'"
bind -N "Create session" C new-session -c "#{pane_current_path}"
bind -N "Kill session" K kill-session
bind -N "Previous session" P switch-client -p
bind -N "Next session" N switch-client -n
bind -N "Previous session" -n M-Up switch-client -p
bind -N "Next session" -n M-Down switch-client -n
# General
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",*:RGB"
set -g mouse on
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
set -g history-limit 50000
set -g escape-time 0
set -g focus-events on
set -g set-clipboard on
set -g allow-passthrough on
setw -g aggressive-resize on
set -g detach-on-destroy off
set -g extended-keys on
set -g extended-keys-format csi-u
set -ag terminal-features "xterm-kitty:extkeys"
set -as terminal-features ",*:clipboard"
set -sg escape-time 10
# Alerts
set-hook -g alert-bell 'run-shell -b "omarchy-shell -q omarchy.indicators refresh"'
set-hook -g alert-activity 'run-shell -b "omarchy-shell -q omarchy.indicators refresh"'
set-hook -g alert-silence 'run-shell -b "omarchy-shell -q omarchy.indicators refresh"'
set-hook -g after-select-window 'run-shell -b "omarchy-tmux-alert track #{window_id} #{window_activity}"'
set-hook -g client-session-changed 'run-shell -b "omarchy-tmux-alert track #{window_id} #{window_activity}"'
set-hook -g client-focus-out[100] 'run-shell -b "omarchy-tmux-alert track #{window_id} #{window_activity}"'
set-hook -g client-focus-in[100] 'run-shell -b "omarchy-tmux-alert track #{window_id} #{window_activity}"'
# Status bar
set -g status-position top
set -g status-interval 5
set -g status-left-length 30
set -g status-right-length 50
set -g window-status-separator ""
set -gw automatic-rename on
set -gw automatic-rename-format '#{b:pane_current_path}'
set -g set-titles on
set -g set-titles-string '#h:#W'
# Theme
set -g status-style "bg=default,fg=default"
set -g status-left "#[fg=black,bg=blue,bold] #S #[bg=default] "
set -g status-right "#[fg=blue]#{?pane_in_mode,COPY ,}#{?client_prefix,PREFIX ,}#{?window_zoomed_flag,ZOOM ,}#[fg=brightblack]#h "
set -g window-status-format "#[fg=brightblack] #I:#W "
set -g window-status-current-format "#[fg=blue,bold] #I:#W "
set -g pane-border-style "fg=brightblack"
set -g pane-active-border-style "fg=blue"
set -g message-style "bg=default,fg=blue"
set -g message-command-style "bg=default,fg=blue"
set -g mode-style "bg=blue,fg=black"
setw -g clock-mode-colour blue