-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmux.conf
More file actions
259 lines (207 loc) · 9.63 KB
/
Copy pathtmux.conf
File metadata and controls
259 lines (207 loc) · 9.63 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
# ==============================================================================
# Samvit's tmux configuration
# ==============================================================================
# Designed to complement vim workflow (leader=,, Ctrl+hjkl for vim splits)
# Optimized for AI agent collaboration (Claude Code, etc.)
# ==============================================================================
# ------------------------------------------------------------------------------
# GENERAL SETTINGS
# ------------------------------------------------------------------------------
# Use Ctrl+a as prefix (easier to reach than Ctrl+b, screen-style)
set -g prefix C-a
unbind C-b
bind C-a send-prefix # Press Ctrl+a twice to send literal Ctrl+a
# Enable 256 color and true color support (matches your vividchalk colorscheme)
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",xterm-256color:Tc"
# Reduce escape time for vim responsiveness (you have timeoutlen=250 in vim)
set -sg escape-time 10
# Large scrollback history (matches your HISTSIZE=20000 preference)
set -g history-limit 50000
# Enable mouse support (matches your mouse=a in vim)
set -g mouse on
# Start window and pane numbering at 1 (easier keyboard access)
set -g base-index 1
setw -g pane-base-index 1
# Renumber windows when one is closed (keep numbering sequential)
set -g renumber-windows on
# Don't rename windows automatically (keep your chosen names)
set -g allow-rename off
# Increase display time for messages
set -g display-time 2000
set -g display-panes-time 2000
# Focus events for vim autoread
set -g focus-events on
# ------------------------------------------------------------------------------
# KEY BINDINGS
# ------------------------------------------------------------------------------
# Reload config with prefix+r
bind r source-file ~/.tmux.conf \; display "Config reloaded!"
# Split panes with | and - (intuitive: | is vertical divider, - is horizontal)
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# New windows open in current directory
bind c new-window -c "#{pane_current_path}"
# Vim-style pane navigation with prefix+hjkl
# (Ctrl+hjkl stays reserved for your vim split navigation)
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Pane resizing with prefix+HJKL (uppercase = resize)
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Quick window navigation
bind -r p previous-window # prefix+p = previous window
bind -r n next-window # prefix+n = next window
# Swap panes (like your vim sH/sJ/sK/sL window moves)
bind > swap-pane -D
bind < swap-pane -U
# ------------------------------------------------------------------------------
# COPY MODE (VI STYLE)
# ------------------------------------------------------------------------------
# Use vi keys in copy mode (matches your vim muscle memory)
setw -g mode-keys vi
# Enter copy mode with prefix+[
# v to start selection (like vim visual mode)
# y to yank (copy)
# p to paste
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-selection-and-cancel
bind -T copy-mode-vi V send -X select-line
bind -T copy-mode-vi r send -X rectangle-toggle
# Use system clipboard (matches your clipboard=unnamed in vim)
# macOS specific - uses pbcopy
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy"
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "pbcopy"
# Paste with prefix+p (but we use p for prev-window, so use P for paste)
bind P paste-buffer
# ------------------------------------------------------------------------------
# STATUS BAR (DARK/MINIMAL - MATCHES VIVIDCHALK)
# ------------------------------------------------------------------------------
# Status bar position
set -g status-position bottom
set -g status-justify left
# Update status bar every 5 seconds
set -g status-interval 5
# Status bar colors (dark theme)
set -g status-style "bg=#1c1c1c,fg=#a8a8a8"
# Left side: session name
set -g status-left-length 40
set -g status-left "#[fg=#87af5f,bold][#S] "
# Right side: pane title, date, time
set -g status-right-length 80
set -g status-right "#[fg=#5f87af]#{pane_title} #[fg=#666666]| #[fg=#a8a8a8]%Y-%m-%d #[fg=#e4e4e4]%H:%M "
# Window status formatting
setw -g window-status-format "#[fg=#666666] #I:#W "
setw -g window-status-current-format "#[fg=#87af5f,bold] #I:#W* "
# Pane borders
set -g pane-border-style "fg=#444444"
set -g pane-active-border-style "fg=#87af5f"
# Message/command styling
set -g message-style "bg=#1c1c1c,fg=#e4e4e4"
# ------------------------------------------------------------------------------
# AI AGENT COLLABORATION FEATURES
# ------------------------------------------------------------------------------
# These settings and bindings help when working with Claude Code or other
# AI coding agents that use tmux for server management and introspection.
# Set pane title (useful for agents to identify what's running where)
# Usage: prefix+T then type a name
bind T command-prompt -p "Pane title:" "select-pane -T '%%'"
# Capture pane contents to a file (agent can read this for context)
# Usage: prefix+C captures last 5000 lines to /tmp/tmux-capture-<pane>.txt
bind C capture-pane -pS -5000 \; save-buffer "/tmp/tmux-capture-#{session_name}-#{window_index}-#{pane_index}.txt" \; display "Pane captured to /tmp/tmux-capture-#{session_name}-#{window_index}-#{pane_index}.txt"
# Quick capture last 100 lines to clipboard (for pasting to agent)
bind Y capture-pane -pS -100 \; save-buffer - \; run "tmux show-buffer | pbcopy" \; display "Last 100 lines copied to clipboard"
# Clear pane history (useful before starting a task you want to capture cleanly)
bind X clear-history \; display "Pane history cleared"
# Show pane info (helpful for debugging agent interactions)
bind I display "Session: #{session_name} | Window: #I:#{window_name} | Pane: #P | Title: #{pane_title} | PID: #{pane_pid}"
# Enable logging for current pane (toggle with prefix+M)
# Logs go to ~/tmux-logs/ with timestamp
bind M pipe-pane -o "cat >> ~/tmux-logs/#{session_name}-#{window_index}-#{pane_index}-$(date +%Y%m%d-%H%M%S).log" \; display "Logging toggled for this pane (check ~/tmux-logs/)"
# List all panes across all sessions (useful for agent to find running servers)
bind A display-popup -E -w 80 -h 20 "tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} [#{pane_title}] #{pane_current_command} #{pane_current_path}' | less"
# Send Ctrl+C to a pane (useful for stopping servers)
bind Q send-keys C-c
# Synchronize input to all panes in window (toggle)
bind S setw synchronize-panes \; display "Synchronize panes: #{?synchronize-panes,ON,OFF}"
# Create a named session quickly (agents prefer named sessions)
bind N command-prompt -p "New session name:" "new-session -s '%%'"
# ------------------------------------------------------------------------------
# HOOKS FOR AUTOMATION
# ------------------------------------------------------------------------------
# Automatically create log directory if it doesn't exist
run-shell "mkdir -p ~/tmux-logs"
# Set default pane title to current command (helpful for identification)
set -g pane-border-format "#{pane_index}: #{pane_title} (#{pane_current_command})"
set -g pane-border-status off # Enable with: set -g pane-border-status top
# ------------------------------------------------------------------------------
# PLUGINS (MINIMAL - PER YOUR PREFERENCE)
# ------------------------------------------------------------------------------
# Using TPM (Tmux Plugin Manager) for just essential plugins
# tmux-yank: System clipboard integration (matches your clipboard=unnamed)
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-yank'
# tmux-resurrect: Save/restore sessions (great for AI agent workflows)
# prefix+Ctrl+s to save, prefix+Ctrl+r to restore
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-strategy-vim 'session' # Restore vim sessions too
# Initialize TPM (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# ==============================================================================
# QUICK REFERENCE
# ==============================================================================
# Prefix: Ctrl+a
#
# PANES:
# prefix + | Split vertical
# prefix + - Split horizontal
# prefix + hjkl Navigate panes
# prefix + HJKL Resize panes
# prefix + x Close pane
# prefix + z Zoom/unzoom pane
# prefix + T Set pane title
# prefix + Q Send Ctrl+C (stop)
#
# WINDOWS:
# prefix + c New window
# prefix + n/p Next/prev window
# prefix + 1-9 Go to window N
# prefix + , Rename window
#
# SESSIONS:
# prefix + N New named session
# prefix + s List sessions
# prefix + d Detach
# prefix + $ Rename session
#
# COPY MODE:
# prefix + [ Enter copy mode
# v Start selection
# V Select line
# y Yank (copy)
# prefix + P Paste
# prefix + Y Copy last 100 lines to clipboard
#
# AI/AGENT HELPERS:
# prefix + C Capture pane to /tmp/
# prefix + X Clear pane history
# prefix + I Show pane info
# prefix + M Toggle pane logging
# prefix + A List all panes (popup)
# prefix + S Sync input to all panes
#
# SESSION PERSISTENCE:
# prefix + Ctrl+s Save sessions (resurrect)
# prefix + Ctrl+r Restore sessions (resurrect)
#
# OTHER:
# prefix + r Reload config
# prefix + ? List all keybindings
# ==============================================================================