-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtmux.conf
More file actions
162 lines (121 loc) · 4.8 KB
/
tmux.conf
File metadata and controls
162 lines (121 loc) · 4.8 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
# Use right thumb finger to press alt and left pinky to press a.
# Make sure that alt keys acts as +Esc in your terminal:
# kitty: `macos_option_as_alt yes`
# Ghostty: `macos-option-as-alt = true`
set -g prefix M-a
# Keep long history
set -g history-limit 1000000
# Fix Vim ESC delay
set -sg escape-time 0
## Panes
# Start windows and panes at 1, not 0
set -g base-index 1
set-window-option -g pane-base-index 1
# Renumber windows after one of them was closed
set-option -g renumber-windows on
# Remove technical information (hostname, time) from tab pane
set -g status-left ''
set -g status-right ''
# Don't ask confirmation about window closing.
bind-key & kill-window
bind-key x kill-pane
# Use hljk for selecting panes
bind h select-pane -L
bind l select-pane -R
bind j select-pane -D
bind k select-pane -U
# Move windows left and right
bind-key H swap-window -d -t -1
bind-key L swap-window -d -t +1
# Highlight panes with recent activity
set-window-option -g monitor-activity on
# Open new splits and new panes in the same directory current pane in
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# Use size of the smallest client only if it is active
set-window-option -g aggressive-resize on
## Mouse and copy mode
# Use vim keys in copy mode
set-window-option -g mode-keys vi
# Mouse is enabled to enable proper selection in multiple panes
set -g mouse on
# Allow selection with mouse
set-option -g word-separators " ()[]{},'\""
unbind-key -T root DoubleClick1Pane
bind-key -T root DoubleClick1Pane select-pane \; copy-mode -M \; send-keys -X select-word
unbind-key -T copy-mode-vi DoubleClick1Pane
bind-key -T copy-mode-vi DoubleClick1Pane send-keys -X select-word
unbind-key -T root TripleClick1Pane
bind-key -T root TripleClick1Pane select-pane \; copy-mode -M \; send-keys -X select-line
unbind-key -T copy-mode-vi TripleClick1Pane
bind-key -T copy-mode-vi TripleClick1Pane send-keys -X select-line
unbind-key -T copy-mode-vi MouseDragEnd1Pane
unbind-key -T copy-mode-vi MouseDown1Pane
bind-key -T copy-mode-vi MouseDown1Pane select-pane \; send-keys -X clear-selection
# Use v in copy mode to start selection and use y to copy text (as in vim)
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
## Integration with terminals
# Pass OSC 52 and other sequences to external terminal (e.g. kitty)
set -g allow-passthrough on
# When copying in tmux, make tmux use OSC 52 sequences
set -g set-clipboard on
# Make tmux pass key combinations to the apps
# May be not needed since tmux 3.5 but we may have older tmux on servers
#
# Tmux doesn't support kitty's keyboard protocol and would never proxy app's request
# to terminal to enable it. tmux could understand CSI-u sequences, but the problem
# is kitty won't send them unless kitty's keyboard protocol is enabled.
# Ghostty sends CSI-u sequences without explicit request from an app.
# In order to make shift+enter (common combination in AI agents TUI) work in kitty,
# you would need to instruct it to send CSI-u sequence on shift+enter:
# kitty: map shift+enter send_text all \033[13;2u
set -g extended-keys always
set -ag terminal-features ',*:extkeys'
set -g extended-keys-format csi-u
## Status bar
set -g status-position top
set -g status-bg '#000000'
set -g status-fg '#bbbbbb'
set -g window-status-current-style bg=blue,fg='#ffffff'
# You can run tmux on remote host.
# Press "Alt+a a" and any further "Alt+a" will go to tmux on remote host. Temporarily,
# Alt+b will act as prefix on local tmux instance. Press "Alt+b b" to switch back to
# using "Alt+a" as prefix locally.
set -ag status-left '#{?@alt-b-leader,[Alt + b] ,}'
bind-key a \
set prefix M-b \; \
set status-bg '#333333' \; \
set @alt-b-leader 1 \; \
refresh-client -S
bind-key b \
set prefix M-a \; \
set status-bg '#000000' \; \
set @alt-b-leader 0 \; \
refresh-client -S
# We assume that users have macbooks with top notch and that's why we make
# status bar 2-line height.
# Perhaps we could use a better method for this
if-shell '[ $(uname -s) = "Darwin" ]' {
if-shell '! tmux show -gv @default-status-format 2>/dev/null' {
run-shell 'tmux set -g @default-status-format "$(tmux show -gv status-format[0])"'
}
set -g status-format[0] '#{?@alt-b-leader,#{E:@default-status-format},}'
set -g status-format[1] '#{?@alt-b-leader,,#{E:@default-status-format}}'
set -g status 2
bind-key a \
set @alt-b-leader 1 \; \
set status on \; \
set status-bg '#333333' \; \
set prefix M-b \; \
refresh-client -S
bind-key b \
set @alt-b-leader 0 \; \
set status 2 \; \
set status-bg '#000000' \; \
set prefix M-a \; \
refresh-client -S
}
## Load local config
if-shell "[ -f ~/.tmux.conf.local ]" 'source ~/.tmux.conf.local'