-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtmux.conf
More file actions
316 lines (264 loc) · 12.5 KB
/
Copy pathtmux.conf
File metadata and controls
316 lines (264 loc) · 12.5 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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#Justyn's tmux config
# Justyn Shull <justyns <at> justynshull.com>
#URL References I used to create this config:
# http://mutelight.org/articles/practical-tmux
# https://bbs.archlinux.org/viewtopic.php?id=84157
# http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/
# http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/
# http://cheasy.de/tmux.pdf
# http://www.edschmalzle.com/2010/09/29/getting-into-tmux/
# http://tonkersten.com/2011/07/104-switching-to-tmux/
# http://www.linuxized.com/2010/05/switching-from-gnu-screen-to-tmux/
# https://wiki.archlinux.org/index.php/Tmux
# https://chadaustin.me/2024/02/tmux-config/
# https://hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
# https://github.com/hamvocke/dotfiles/blob/master/tmux/.tmux.conf
## Shortcuts to remember
# Ctrl+a is the 'prefix' / control key
# ctrl+a ? - displays custom help (clean, searchable shortcut list)
# ctrl+a ctrl+a - switches between last active window
# ctrl+a , - renames current window
# ctrl+a | - splits window vertically
# ctrl+a \ - splits window vertically (alternative)
# ctrl+a - - splits window horizontally
# ctrl+a q - displays numbers on each pane. Press the number to go to that pane
# ctrl+a o - cycle through panes
# ctrl+a ctrl+o - cycle panes into the pane you're currently viewing
# ctrl+a n,p - next/previous windows same as screen
# ctrl+a <space>- changes default layout of your panes (even-horiz, even-vert, etc)
# ctrl+a alt+arrowkeys - resizes current window pane in the direction of the arrow key
# ctrl+a [ - enter copy mode
# ctrl+a a <com>- sends <com> to nested screen or tmux session
# ctrl+a x - kill a pane(or window)
# ctrl+a w/W - fzf window switcher popup (replaces default window list)
# ctrl+a " - choose window (interactive window selector)
# ctrl+a s/S - fzf session switcher popup (replaces default session list)
# ctrl+a f - fzf agent picker
# ctrl+a : new -s <session name> - create a new session
# ctrl+a R - reload / source .tmux.conf
# ctrl+a A - rename current window
# ctrl+a k - kill window
# ctrl+a m - turn on/off monitor_activity for a window(useful for irssi)
# ctrl+a M - toggle mouse mode
# ctrl+a b/B - switch prefix from ctrl+a to ctrl+b or back
# ctrl+a X - break pane to its own window
# ctrl+a j - bring a window in to current window as a pane (ie: join-pane 0:1)
# ctrl+a T <pos>- move current window to position <pos>
# ctrl+left - move current window one spot to the left
# ctrl+right - move current window one spot to the right
# ctrl+a u - copy the current window/pane and pipe it to urlview to grab all the urls
# ctrl+a z - Zoom into the current pane, press again to zoom back out (useful for copying text)
# ctrl+a c-c - create new window after current window
# shift+left/right - move current window left/right and follow it
#
## Alt key shortcuts (no prefix needed)
# alt+1-9 - switch to window 1-9
# alt+h/j/k/l - navigate panes (vim-style: left/down/up/right)
# alt+n/m - navigate panes (left/right)
#
## Shell shortcuts (work outside tmux too)
# ctrl+r - atuin+fzf history search (popup in tmux, regular fzf outside)
#
## Commands to remember
# :setw synchronize-panes [on|off] - Synchronize panes on the current window, sends input to all of them at the same time.
# :movew -r - Renumber (compact) all windows to fill in gaps. Can also use movew <num> to renumber the current window to <num>.
##Display##
# Set status bar
# Catppuccin theme configuration
set -g @catppuccin_flavor "frappe" # latte, frappe, macchiato, or mocha
set -g @catppuccin_window_status_style "rounded" # basic, rounded, slanted, custom, or none
set -g @catppuccin_status_left_separator "█"
set -g @catppuccin_status_right_separator "█"
# Window naming logic:
# - If manually renamed: show custom name (#W)
# - If auto-rename enabled: show directory name for zsh, command name for others
# - Special case for SSH: try to show destination host
set -g @catppuccin_window_text " #{?#{==:#{@agent_state},waiting},! ,}#{?#{@agent_project},#{?#{@agent_tag},#{@agent_tag},cc}:#{=/14/…:#{@agent_project}},#{?#{==:#{pane_current_command},claude},cc:#{=/14/…:#{b:pane_current_path}},#{?#{==:#{pane_current_command},zsh},#{b:pane_current_path},#{pane_current_command}}}}"
set -g @catppuccin_window_current_text " #{?#{==:#{@agent_state},waiting},! ,}#{?#{@agent_project},#{?#{@agent_tag},#{@agent_tag},cc}:#{=/14/…:#{@agent_project}},#{?#{==:#{pane_current_command},claude},cc:#{=/14/…:#{b:pane_current_path}},#{?#{==:#{pane_current_command},zsh},#{b:pane_current_path},#{pane_current_command}}}}"
set-option -g status-justify left
set-option -g status-left-length 40
set-option -g status-right-length 90
# Set window notifications
setw -g monitor-activity on
setw -g visual-activity off
# Automatically set window title to command that is running
setw -g automatic-rename on
set-option -g allow-rename on
set-option -g automatic-rename-format '#{?#{m/r:^(claude|aider|opencode|crush|goose|amp|cursor-agent)$,#{pane_current_command}},#{?#{!=:#{pane_title},},#{=/20/…:#{s|^[^ ]* ||:pane_title}},#{pane_current_command}},#{?#{@agent_project},#{?#{@agent_tag},#{@agent_tag},cc}:#{=/16/…:#{@agent_project}},#{?#{==:#{pane_current_command},zsh},#{b:pane_current_path},#{pane_current_command}}}}'
set-option -g status-interval 1
# Change binding to ctrl+a like screen
unbind-key C-b
set-option -g prefix C-a
# Set tmux to vi mode keys for copy-mode
setw -g mode-keys vi
# Behave the same way as screen with nested multiplexers
# IE: C-a a <command> sends <command> to inner screen/tmux
bind-key a send-prefix
# Start Window and Pane Numbering at 1
set -g base-index 1
set -g pane-base-index 1
# Rather than constraining window size to the maximum size of any client
# connected to the *session*, constrain window size to the maximum size of any
# client connected to *that window*. Much more reasonable.
setw -g aggressive-resize on
# no more delay bhetween ctrl+a and a sequence
set -s escape-time 0
# Fix problems with scrolling in some terminals
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# From http://tonkersten.com/2011/07/104-switching-to-tmux/
set-option -g history-limit 100000
#set-option -g pane-active-border-bg default
#set-option -g pane-active-border-fg red
#set-option -g pane-border-bg default
#set-option -g pane-border-fg cyan
#set-window-option -g window-status-format ' #I:#W '
#set-window-option -g window-status-current-format ' (#I:#W) '
set-window-option -g window-status-format '#I:#W#F'
set-window-option -g window-status-current-format '#I:#W#F'
# From http://dev.gentoo.org/~wired/conf/tmux.conf
set-option -g mouse on
set-option -g status-keys vi
set-option -g bell-action any
set-option -g set-titles on
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # window number,program name,active (or not)
##Keybindings
# Change some keybindings to match screen and be easier to use
# Ctrl+a ctrl+a - switch to last active window
# ctrl+a | and - to split the window(horiz and vert)
bind-key C-a last-window
bind a send-prefix
unbind %
bind | split-window -h
bind '\' split-window -h
bind - split-window -v
bind C-c new-window
bind k confirm-before "kill-window"
bind C-k confirm-before "kill-window"
bind m setw monitor-activity
bind M set -g mouse
#bind s list-sessions
# Hide and show window name from status line
#bind '_' setw window-status-format '#I'\; setw window-status-current-format '#I'
#bind '+' setw window-status-format '#I:#W#F'\; setw window-status-current-format '#I:#W#F'
# Easy reloading of config file
bind-key R source-file ~/.tmux.conf \; display-message "source-file done"
# Rename like in screen
bind A command-prompt "rename-window %%"
# Change prefix key from ctrl+a to ctrl+b and back
bind B set-option -g prefix C-a
bind b set-option -g prefix C-b
bind C-x set-option -g prefix C-x
# From https://bbs.archlinux.org/viewtopic.php?id=84157&p=5
# "Some guys in the irc liked a trick I use with tmux and urlview to grab/browse url's
# from terminal applications run in tmux (most use it with mutt),
# so I post it here too for reference ..."
bind-key u capture-pane \; save-buffer /tmp/tmux-buffer \; new-window -n "urlview" '$SHELL -c "urlview < /tmp/tmux-buffer"'
# From http://unix.stackexchange.com/questions/14300/tmux-move-window-to-pane
bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'"
#bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'"
bind X break-pane
# kill K k
unbind K
bind K confirm-before "kill-window"
unbind k
bind k confirm-before "kill-window"
# windows ^W w
unbind ^W
bind ^W list-windows
unbind w
bind '"' choose-window
# From http://superuser.com/questions/343572/how-do-i-reorder-tmux-windows
# c-a T and then a number to move the current window to that position
# Similar to screen's :number
bind-key T command-prompt -p "move window to:" "swap-window -t '%%'"
# c-a-left arrow to move window left
# c-a-right arrow to move window right
bind-key C-Left swap-window -t -1
bind-key C-Right swap-window -t +1
# Set TERM for tmux sessions - force override any defaults
set -g default-terminal "tmux-256color"
# Enable truecolor support for terminals that support it
set -ga terminal-overrides ",xterm-ghostty:Tc"
set -ga terminal-overrides ",*256col*:Tc"
# Select windows with alt+number key
bind-key -n M-1 select-window -t 1
bind-key -n M-2 select-window -t 2
bind-key -n M-3 select-window -t 3
bind-key -n M-4 select-window -t 4
bind-key -n M-5 select-window -t 5
bind-key -n M-6 select-window -t 6
bind-key -n M-7 select-window -t 7
bind-key -n M-8 select-window -t 8
bind-key -n M-9 select-window -t 9
# Use hjkl to move around panes
bind-key -n M-h select-pane -L
bind-key -n M-j select-pane -D
bind-key -n M-k select-pane -U
bind-key -n M-l select-pane -R
bind -n M-n select-pane -L
bind -n M-m select-pane -R
bind -n M-k select-pane -U
bind -n M-j select-pane -D
# Create new window after active window
bind "C-c" new-window -a
# Move current window to the left or right
bind "S-Left" {
swap-window -t -1
select-window -t -1
}
bind "S-Right" {
swap-window -t +1
select-window -t +1
}
# fzf session and window switching
bind-key s display-popup -E -w 90% -h 80% '$HOME/bin/tmux-pick session'
bind-key S display-popup -E -w 90% -h 80% '$HOME/bin/tmux-pick session'
bind-key w display-popup -E -w 90% -h 80% '$HOME/bin/tmux-pick window'
bind-key W display-popup -E -w 90% -h 80% '$HOME/bin/tmux-pick window'
# lazygit popup
bind-key g display-popup -E -xC -yC -w 80% -h 80% -d "#{pane_current_path}" lazygit
# Claude Code popup (TODO: Not sure if I like this or not yet)
bind-key C if-shell -F '#{==:#{session_name},claude}' {
detach-client
} {
set -gF '@last_session_name' '#S'
popup -d '#{pane_current_path}' -xC -yC -w90% -h90% -E 'tmux new -A -s claude -c "#{pane_current_path}" "claude"'
}
# Custom help display (replaces default ? binding)
bind-key ? display-popup -E -w 90% -h 80% "echo 'TMUX SHORTCUTS:
Window/Session Management:
ctrl+a w/W - fzf window switcher popup
ctrl+a s/S - fzf session switcher popup
ctrl+a \" - choose window (interactive)
ctrl+a ctrl+a - switch to last active window
ctrl+a , - rename current window
Pane Management:
ctrl+a | - split window vertically
ctrl+a - - split window horizontally
ctrl+a z - zoom/unzoom current pane
ctrl+a X - break pane to new window
ctrl+a j - join pane from another window
Quick Navigation:
alt+1-9 - switch to window 1-9
alt+h/j/k/l - navigate panes (vim-style)
Other Shortcuts:
ctrl+a f - agent picker
ctrl+a g - lazygit popup
ctrl+a C - Claude Code popup (persistent session)
ctrl+a R - reload tmux config
ctrl+r - atuin+fzf history search
shift+left/right - move window left/right
' | less"
# Claude Code inside tmux: https://code.claude.com/docs/en/terminal-config
# Passthrough for its notifications, extended-keys for Shift+Enter.
set -g allow-passthrough on
set -s extended-keys on
set -as terminal-features 'xterm*:extkeys'
# Load machine-specific tmux config if there is one
if '[ -e ~/.tmux-local.conf ]' 'source-file ~/.tmux-local.conf'
# Load Catppuccin theme (must be at the end)
run ~/.config/tmux/plugins/catppuccin/catppuccin.tmux
# tmux-agent: After the theme to fix a few things
bind-key f display-popup -E -w 90% -h 80% '$HOME/bin/tmux-agent pick'
set-hook -g pane-exited 'run-shell -b "$HOME/bin/tmux-agent clean >/dev/null 2>&1"'
set -g status-right '#($HOME/bin/tmux-agent summary) #{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,}#{=/22/…:#{s|^[^ ]* ||:pane_title}} %H:%M %d-%b-%y'