Add heartbeat.sh that tracks session active time using three native tmux signals: client input (+5), window output (+2), and copy mode (+2), with -1 decay per tick. Score drives a block bar indicator and accumulated active time counter. Resets on tmux server restart. Status bar updates: - Heartbeat pill with pressure bar right of clock - Responsive breakpoints: hide network/battery <120 cols, date <80 - Click clock/date to toggle condensed view - Click heartbeat to instant-lock session - Static colon in clock (replaces shell-based blinker) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
101 lines
3.4 KiB
Bash
101 lines
3.4 KiB
Bash
# Prefix: Ctrl+A
|
||
unbind C-b
|
||
set -g prefix C-a
|
||
bind C-a send-prefix
|
||
|
||
# True color
|
||
set -g default-terminal "tmux-256color"
|
||
set -s terminal-overrides "xterm-256color:RGB"
|
||
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
|
||
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
|
||
|
||
# Shell
|
||
set -g default-shell "$SHELL"
|
||
|
||
# Windows and panes start at 1
|
||
set -g base-index 1
|
||
setw -g pane-base-index 1
|
||
set -g renumber-windows on
|
||
set -g history-limit 100000
|
||
set -sg escape-time 10
|
||
set -g focus-events on
|
||
set -g display-time 4000
|
||
|
||
# Mouse
|
||
set -g mouse on
|
||
set -g set-clipboard on
|
||
set -g @condensed 0
|
||
bind -T root MouseDown1StatusRight if-shell \
|
||
"[ $(( #{mouse_x} )) -ge $(( #{client_width} - 9 )) ]" \
|
||
"lock-session" \
|
||
'if-shell "[ \"$(tmux show-option -gqv @condensed)\" = 1 ]" "set -g @condensed 0" "set -g @condensed 1"'
|
||
|
||
# Copy mode
|
||
setw -g mode-keys vi
|
||
bind -T copy-mode-vi v send -X begin-selection
|
||
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy 2>/dev/null || xclip -selection clipboard 2>/dev/null || xsel --clipboard"
|
||
bind -T copy-mode-vi MouseDown1Pane send -X clear-selection
|
||
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "pbcopy 2>/dev/null || xclip -selection clipboard 2>/dev/null || xsel --clipboard"
|
||
|
||
# Splits
|
||
bind | split-window -h -c "#{pane_current_path}"
|
||
bind - split-window -v -c "#{pane_current_path}"
|
||
unbind '"'
|
||
unbind %
|
||
|
||
bind c new-window -c "#{pane_current_path}"
|
||
|
||
# Pane navigation
|
||
bind h select-pane -L
|
||
bind j select-pane -D
|
||
bind k select-pane -U
|
||
bind l select-pane -R
|
||
|
||
# Pane resize
|
||
bind -r C-h resize-pane -L 5
|
||
bind -r C-j resize-pane -D 5
|
||
bind -r C-k resize-pane -U 5
|
||
bind -r C-l resize-pane -R 5
|
||
|
||
# Quick switch to last window
|
||
bind a last-window
|
||
|
||
# Reload
|
||
bind r source-file ~/.tmux.conf \; display "Config reloaded"
|
||
|
||
# Screensaver
|
||
bind S lock-session
|
||
|
||
# Status bar
|
||
set -g status-position bottom
|
||
set -g status-interval 1
|
||
set -g status-style "fg=#7290B8,bg=default"
|
||
set -g status-left "#{?client_prefix,#[fg=colour208]● ,#[fg=#3C3C3C]● }"
|
||
set -g status-right "#{?@condensed,,#{?#{e|>=|:#{client_width},120},#(~/.tmux/network.sh) #[fg=#3C3C3C] #(~/.tmux/battery.sh) #[fg=#3C3C3C] ,}}#{?@condensed,,#{?#{e|>=|:#{client_width},80},#[fg=#808080]%a %d %b ,}}#{?@condensed,#[fg=#3C3C3C]‹,}#[fg=#2CB494]#[bg=#1A1A1A] %H:%M #[default]#(~/.tmux/heartbeat.sh)"
|
||
set -g status-right-length 80
|
||
set -g window-status-format "#{?window_last_flag, #[fg=#1A7A64]#I#[fg=default] #W , #I #W }"
|
||
set -g window-status-current-format " #[fg=#085040]#I#[fg=#0A0A0A] #W "
|
||
set -g window-status-separator " "
|
||
set -g window-status-style "fg=#808080,bg=#1A1A1A"
|
||
set -g window-status-current-style "fg=#0A0A0A,bg=#2CB494,bold"
|
||
set -g window-status-bell-style "fg=colour234,bg=colour208,bold"
|
||
set -g monitor-bell on
|
||
set -g visual-bell off
|
||
set -g pane-border-style "fg=#3C3C3C"
|
||
set -g pane-active-border-style "fg=#2CB494"
|
||
set -g message-style "fg=#2CB494,bg=default"
|
||
set -g message-command-style "fg=#F88C14,bg=default"
|
||
set -g mode-style "fg=colour255,bg=colour30,bold"
|
||
set -g display-panes-colour "#808080"
|
||
set -g display-panes-active-colour "#2CB494"
|
||
|
||
# Clock
|
||
set -g clock-mode-colour "#2CB494"
|
||
|
||
# Screensaver
|
||
set -g lock-after-time 180
|
||
set -g lock-command 'eval $(grep active_total ${TMPDIR:-/tmp}/.tmux_heartbeat 2>/dev/null); ~/.tmux/donut ${active_total:-0}'
|
||
set -g automatic-rename on
|
||
set -g allow-rename off
|
||
set -g automatic-rename-format '#(~/.tmux/tab-name.sh "#{pane_current_command}" "#{b:pane_current_path}")'
|