-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdot_tmux.conf
More file actions
293 lines (242 loc) · 11.9 KB
/
dot_tmux.conf
File metadata and controls
293 lines (242 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# WARNING: Do not bind C-M!! The terminal sees this as <return> being pressed.
# If you set it on accident, you will need to manually unset it :unset -m C-M,
# or start a new session.
#--------------------------------------------
# ~ Options ~
#--------------------------------------------
set -g history-limit 50000
# Increase tmux message display duration.
set -g display-time 3000
# Style messages to be more visible (centered, bright colors)
set -g message-style "bg=green,fg=black,bold,align=centre"
set -g message-command-style "bg=yellow,fg=black,bold,align=centre"
# Refresh 'status-left' and 'status-right' more often, from every 15s to 5s
set -g status-interval 5
# Needed for neovim
# Suggested by lazyvim's :checkhealth
set -sg escape-time 10
set -g focus-events on
# True color settings
set -s default-terminal 'tmux-256color'
set -sa terminal-features ',tmux-256color:RGB'
set -as terminal-overrides ',alacritty*:Tc'
# required for pi ai
set -g extended-keys on
set -g extended-keys-format csi-u
set -g mode-keys vi
# End Neovim Specific
# Super useful when using "grouped sessions" and multi-monitor setup
setw -g aggressive-resize on
# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
# Position of status bar
set -g status-position top
set -g status-right ''
set -g status-left '#{tmux_mode_indicator} '
# Used for sesh.
set -g detach-on-destroy off # don't exit from tmux when closing a session
#--------------------------------------------
# ~ Keybinds ~
#--------------------------------------------
# Reload Config
bind-key r source-file ~/.local/share/chezmoi/dot_tmux.conf \; display-message -d 2000 "~/.tmux.conf reloaded"
# Searchable keybinding reference (replaces built-in list-keys)
bind-key ? display-popup -E -w 90% -h 90% "$HOME/code/scripts/tmux/tmux-keys-fzf"
# Restart current pane
bind-key R respawn-pane -k
bind-key M split-window -h "vim ~/.tmux.conf"
# Vim Copy Settings
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" \; set -p window-active-style ''
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy" \; set -p window-active-style ''
bind -T copy-mode-vi Escape send -X cancel \; set -p window-active-style ''
bind -T copy-mode-vi q send -X cancel \; set -p window-active-style ''
bind P paste-buffer
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy" \; set -p window-active-style ''
# Selection highlight color
set -g mode-style 'bg=#32302f,fg=#ebdbb2,bold'
# Homerow arrow keys in copy mode (colemak-style mnei = left/down/up/right)
bind -T copy-mode-vi m send -X cursor-left
bind -T copy-mode-vi n send -X cursor-down
bind -T copy-mode-vi e send -X cursor-up
bind -T copy-mode-vi i send -X cursor-right
# Quick scroll up - enter copy mode and scroll up with Alt-u (handled below with color)
# Enter copy mode with Alt-v (no leader needed), highlight background
bind-key -n M-v copy-mode \; set -p window-active-style '#{@theme_copy_mode_bg}'
bind-key -n M-u copy-mode -u \; set -p window-active-style '#{@theme_copy_mode_bg}'
# In copy mode, Alt-u/Alt-d to continue scrolling (keep holding Alt)
bind-key -T copy-mode-vi M-u send-keys -X halfpage-up
bind-key -T copy-mode-vi M-d send-keys -X halfpage-down
# Leader Key
set -g prefix C-t
bind-key C-t send-prefix
# set -g prefix C-Space
# bind-key C-Space send-prefix
# RESIZE PANELS
#
# By 5 Pixels
bind-key -r -T prefix C-Up resize-pane -U 5
bind-key -r -T prefix C-Down resize-pane -D 5
bind-key -r -T prefix C-Left resize-pane -L 5
bind-key -r -T prefix C-Right resize-pane -R 5
# By 1 Pixels
bind-key -r -T prefix M-m resize-pane -L
bind-key -r -T prefix M-n resize-pane -D
bind-key -r -T prefix M-e resize-pane -U
bind-key -r -T prefix M-i resize-pane -R
# Panes
# alt mnei to select panes without leader
bind-key -n M-m select-pane -L
bind-key -n M-n select-pane -D
bind-key -n M-e select-pane -U
bind-key -n M-i select-pane -R
# Select Pane using Leader.
bind m select-pane -L
bind n select-pane -D
bind e select-pane -U
bind i select-pane -R
# Create Pane panes using / and -
unbind '"'
unbind %
# Vertical
bind / split-window -h -c "#{pane_current_path}"
# Horizontal
bind - split-window -v -c "#{pane_current_path}"
# Layout Cycling - prefix Space cycles layouts (use prefix first to avoid accidental triggers)
# Removed C-Space root binding - too easy to trigger accidentally
# Windows
# ------------------------------------------------------
# Create
bind c new-window -c "#{pane_current_path}"
# Next
bind-key -n M-I next-window
# Previous
bind-key -n M-M previous-window
# # Move Window Left
# bind-key -n M-M swap-window -t -1
# # Move Window Right
# bind-key -n M-I swap-window -t +1
#
# Misc
# ------------------------------------------------------
# Not sure how this got set in the first place.
unbind -n Tab
# ------------------------------------------------------
# Session Management
# ------------------------------------------------------
# Switch to last active session - Alt-s (no leader needed) or C-t s (with leader)
bind-key -n M-s run-shell "sesh last"
bind-key s run-shell "sesh last"
# Quick session cycling - Alt-Tab style (instant switching)
bind-key -n M-Tab run-shell "$HOME/code/scripts/tmux/session-quick-switch 1"
bind-key -n M-BTab run-shell "$HOME/code/scripts/tmux/session-quick-switch 2"
# Alternative: Visual session switcher with fzf popup
# Uncomment this and comment out the lines above if you prefer to see a list
# bind-key -n M-Tab display-popup -E -w 60% -h 50% "$HOME/code/scripts/tmux/session-visual-switcher /tmp/tmux-session-switch-#{session_id}"
# Sesh session selector - Alt-t (no leader needed) or C-t t (with leader)
bind-key -n M-t run-shell -b "sesh connect \"$(
sesh list --icons | fzf-tmux -p 80%,70% \
--no-sort --ansi --border-label ' sesh ' --prompt '> ' \
--header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find ^w worktrees' \
--bind 'tab:down,btab:up' \
--bind 'ctrl-a:change-prompt(> )+reload(sesh list --icons)' \
--bind 'ctrl-t:change-prompt(tmux> )+reload(sesh list -t --icons)' \
--bind 'ctrl-g:change-prompt(config> )+reload(sesh list -c --icons)' \
--bind 'ctrl-x:change-prompt(zoxide> )+reload(sesh list -z --icons)' \
--bind 'ctrl-f:change-prompt(find> )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
--bind 'ctrl-w:change-prompt(worktree> )+reload(fd -t d -d 2 . ~/code/worktrees 2>/dev/null)' \
--bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(> )+reload(sesh list --icons)' \
--preview-window 'right:55%' \
--preview 'sesh preview {}'
)\""
bind-key t run-shell -b "sesh connect \"$(
sesh list --icons | fzf-tmux -p 80%,70% \
--no-sort --ansi --border-label ' sesh ' --prompt '> ' \
--header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find ^w worktrees' \
--bind 'tab:down,btab:up' \
--bind 'ctrl-a:change-prompt(> )+reload(sesh list --icons)' \
--bind 'ctrl-t:change-prompt(tmux> )+reload(sesh list -t --icons)' \
--bind 'ctrl-g:change-prompt(config> )+reload(sesh list -c --icons)' \
--bind 'ctrl-x:change-prompt(zoxide> )+reload(sesh list -z --icons)' \
--bind 'ctrl-f:change-prompt(find> )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
--bind 'ctrl-w:change-prompt(worktree> )+reload(fd -t d -d 2 . ~/code/worktrees 2>/dev/null)' \
--bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(> )+reload(sesh list --icons)' \
--preview-window 'right:55%' \
--preview 'sesh preview {}'
)\""
# Worktree branch selector - Alt-w (no leader needed) or C-t w (with leader)
# Select repo > select branch > create worktree if needed > start session
bind-key -n M-w display-popup -E -w 80% -h 70% "$HOME/code/scripts/tmux/worktree-branch-selector"
bind-key w display-popup -E -w 80% -h 70% "$HOME/code/scripts/tmux/worktree-branch-selector"
# example of starting a session using output of ls to select from.
# bind-key 'f' run-shell -b "sesh connect \"$(ls | fzf-tmux --ansi --bind 'tab:down,btab:up')\""
# Layout picker - select and apply tmuxinator layouts
bind-key "L" display-popup -E -w 80% -h 80% "$HOME/code/scripts/tmux/layout-picker"
# Theme picker - switch alacritty + tmux themes in real time
bind-key "T" display-popup -E -w 55% -h 70% "$HOME/code/scripts/terminal-theme-picker"
# Command history browser
# M-h: tv version M-y: fzf version (compare and pick your favourite)
# M-H: tmux scrollback fallback (for subshell sessions)
bind-key -n M-h display-popup -E -w 85% -h 80% "$HOME/code/scripts/shell/cmd-history-browse"
bind-key -n M-y display-popup -E -w 85% -h 80% "$HOME/code/scripts/shell/cmd-history-fzf"
bind-key -n M-H display-popup -E -w 85% -h 80% "tv tmux-scrollback"
# Claude pane message picker - copy any message/response from the focused pane
bind-key -n M-c run-shell "tmux display-popup -E -w 85% -h 80% '$HOME/code/scripts/shell/claude-pane-copy #{pane_id}'"
# PR Selector popup - Alt-g for GitHub PRs (toggles on/off)
bind-key -n M-g run-shell "$HOME/code/scripts/github/pr-popup-toggle"
# Start PR cache refresher in background when new sessions are created
# The script has PID file protection to prevent multiple instances
# Settings are read from ~/.config/gh-pr-select/config.yml
set-hook -g after-new-session "run-shell -b '$HOME/code/scripts/github/pr-cache-refresh'"
# Refresh system state cache on new session
set-hook -g after-new-session "run-shell -b '$HOME/code/scripts-private/bin/system-state-check --json --no-fetch > /dev/null 2>&1 || true'"
# Theme colors - loaded from machine-local file (not tracked in git)
source-file -q ~/.config/tmux/themes/current-theme.conf
# Plugins
# ------------------------------------------------------
# Instructions for Tmux Plugin Manager (TPM)
# https://github.com/tmux-plugins/tpm?tab=readme-ov-file#installing-plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'alexwforsythe/tmux-which-key'
# Load which-key init directly (plugin.sh.tmux uses GNU readlink which fails on macOS)
if-shell 'test -f ~/.tmux/plugins/tmux-which-key/plugin/init.tmux' \
'source-file ~/.tmux/plugins/tmux-which-key/plugin/init.tmux'
# Mode indicator styling
set -g @plugin 'MunifTanjim/tmux-mode-indicator'
set -g @mode_indicator_prefix_prompt ' WAIT '
set -g @mode_indicator_copy_prompt ' COPY '
set -g @mode_indicator_empty_prompt ' TMUX '
set -g @mode_indicator_prefix_mode_style 'bg=colour208,fg=colour237,bold'
set -g @mode_indicator_copy_mode_style 'bg=colour142,fg=colour237,bold'
set -g @mode_indicator_empty_mode_style 'bg=colour245,fg=colour237,bold'
# Leader + Space to show the menu.
# set -g @plugin 'z3z1ma/tmux-gruvbox'
# Session persistence
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on' # Auto-restore on tmux start
# Restore programs on session restore
# Note: Claude Code will restart but conversation state won't be restored (use /resume in Claude)
set -g @resurrect-processes 'vi vim nvim emacs man less more tail top htop irssi weechat mutt ~claude'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# Pane border format - placed after plugins
set -g pane-border-status top
set -g pane-border-format " #{pane_index}: #{s|$HOME|~|:pane_current_path} "
set -g pane-border-lines heavy
# Override status bar to show session name in center
# set -g status-centre 'hello'
# Resources
# ------------------------------------------------------
# https://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
# Notes
# ------------------------------------------------------
# -r allows the keybind to repeat without having to hit the leader
# key again.
# The C- portion of this keybind allows you to continue holding down
# control and hit multiple <spc>+a/t to cycle through windows as opposed
# to repaeting a/t which can som etimes be faster.
# bind -r C-t next-window
# bind -r C-a previous-window
#
# vim:syntax=tmux