-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtmux.conf
265 lines (206 loc) · 9.67 KB
/
tmux.conf
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
# -- GENERAL
# Remap prefix key to C-a, which is GNU-Screen compatible.
unbind C-b
set-option -g prefix C-a
bind C-a send-prefix
# Enable xterm-style function key sequences.
set-option -gw xterm-keys on
# Enable mouse mode.
set-option -g mouse on
# Faster command sequences.
set-option -s escape-time 10
# Slower repeat timeout, unit: milliseconds.
set-option -gs repeat-time 600
# Enable focus event.
set-option -s focus-events on
# Boost history.
set-option -g history-limit 5000
# Use UTF-8.
set-option -gqw utf8 on
# Start windows and panes numbering at 1.
set-option -g base-index 1
set-option -gw pane-base-index 1
# Rename window to reflect current program.
set-option -gw automatic-rename on
# Renumber windows when a window is closed.
set-option -g renumber-windows on
# -- DISPLAY
# Colors
# How to use true colors in vim under tmux? #1246
# https://github.com/tmux/tmux/issues/1246:
# Put this in your ~/.tmux.conf and replace XXX by your $TERM outside of tmux:
# $TERM should be "screen-256color" or "tmux-256color" in tmux.
# Solve VIM's problem but lead to Emacs's problem since Emacs can't recognize tmux-256color.
# Try screen-256color (https://github.com/tmux/tmux/issues/622):
# for 2.6 and higher
if-shell "test '\( #{$TMUX_VERSION_MAJOR} -eq 2 -a #{$TMUX_VERSION_MINOR} -ge 6 \)'" 'set -g default-terminal "screen-256color"'
if-shell "test '\( #{$TMUX_VERSION_MAJOR} -eq 2 -a #{$TMUX_VERSION_MINOR} -ge 6 \)'" 'set -sa terminal-overrides ",*256col*:RGB"'
# for 2.5 and lower
if-shell '\( #{$TMUX_VERSION_MAJOR} -eq 2 -a #{$TMUX_VERSION_MINOR} -lt 6\) -o #{$TMUX_VERSION_MAJOR} -le 1' 'set -g default-terminal "screen-256color"'
if-shell '\( #{$TMUX_VERSION_MAJOR} -eq 2 -a #{$TMUX_VERSION_MINOR} -lt 6\) -o #{$TMUX_VERSION_MAJOR} -le 1' 'set -ga terminal-overrides ",screen-256color:Tc"'
# # Enable Neovim cursor shapes in tmux.
# # https://github.com/neovim/neovim/wiki/FAQ#cursor-shape-doesnt-change-in-tmux
# set-option -sa terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[2 q'
# Set terminal title.
set-option -g set-titles on
## Status bar style.
# redraw status line per minute.
set-option -g status-interval 60 # unit, seconds
set-option -g status-style fg=white,bg=black
set-option -g status-left '#[fg=white,bg=magenta] #S '
set-option -g status-right '#{?client_prefix,#[reverse] ^A #[noreverse],} #[fg=white,bg=black]%a %R %p %Y-%m-%d #{USER} #h'
# Position of the window list.
set-option -g status-justify left
# set-option -g status-justify centre
# Set window status style.
set-option -g window-status-separator ''
# Default window style.
# Use `default` to inherit the color of the status bar.
set-option -g window-status-format ' #I:#W#F '
set-option -g window-status-style fg=default,bg=default
# Current window style.
set-option -g window-status-current-format ' #I:#W#F '
set-option -g window-status-current-style fg=black,bg=yellow,bright
# Last active window.
set-option -g window-status-last-style fg=white,bg=default,underscore
# Window with an activity alert.
set-option -g window-status-activity-style fg=cyan,bg=default
# Window with an bell alert.
set-option -g window-status-bell-style fg=red,bg=default
# Set pane border style.
set-option -g pane-border-style fg=colour240,bg=default
set-option -g pane-active-border-style fg=green,bg=default
# # Set the Command Line.
# set-option -g message-style fg=default,bg=yellow
# Clock.
set-option -gw clock-mode-colour green
# -- Key Bindings
# Global:
# prefix r Reload tmux configuration file.
# prefix t Show the time.
# prefix ? List all key bindings.
# prefix : Enter the tmux command prompt.
# ctrl+l Clear both screen and history.
# Reload configuration.
bind r source-file ~/.tmux.conf \; display-message 'tmux configuration reloaded.'
# Clear both screen and history.
bind -n C-l send-keys C-l \; run 'sleep 0.1' \; clear-history
# Session:
# prefix C-c Create a new session.
# prefix s Choose the current session interactively.
# prefix $ Rename the current session.
# prefix d Detach the current client.
# prefix ) Change to the next session.
# prefix ( Change to the previous session.
# Create session.
bind C-c new-session
# Find session.
bind C-f command-prompt -p find-session 'switch-client -t %%'
# Change session.
bind -r ( switch-client -p
bind -r ) switch-client -n
# Window:
# prefix c Create a new window.
# prefix w Choose the current window interactively.
# prefix C-h Change to the next window.
# prefix C-l Change to the previous window.
# prefix f Find opened windows.
# prefix , Rename the current window.
# prefix & Kill the current window.
# prefix C
# Window navigation.
unbind n
unbind p
bind -r C-h previous-window # select previous window
bind -r C-l next-window # select next window
bind Tab last-window # move to last active window
# Add -r to make the key repeatable
# Swap current window.
bind -r M-a swap-window -d -s . -t ^
bind -r M-e swap-window -d -s . -t $
bind -r M-h swap-window -d -s . -t -
bind -r M-l swap-window -d -s . -t +
# Pane:
# prefix | Split the current pane into two, left and right.
# prefix - Split the current pane into two, top and bottom.
# prefix o Select the next pane in the current window.
# prefix q Briefly display pane indexes.
# prefix x Kill the current pane.
# prefix space Arrange the current window in the next preset layout.
# prefix < Swap the current pane with the previous pane.
# prefix > Swap the current pane with the next pane.
# prefix z Toggle zoom state of the current pane.
## the same behavior as Emacs.
# On macOS, new panes will be opened under where the tmux session started.
# Split panes using | and -.
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# Pane navigation.
bind -r h select-pane -L # move left
bind -r j select-pane -D # move down
bind -r k select-pane -U # move up
bind -r l select-pane -R # move right
bind > swap-pane -D # swap current pane with the next one
bind < swap-pane -U # swap current pane with the previous one
# Pane resizing.
bind -r H resize-pane -L 2
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r L resize-pane -R 2
# Check information about processes.
bind T new-window -n processes "top"
# Maximizing and restoring panes.
bind O new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp
bind I last-window \; swap-pane -s tmp.1 \; kill-window -t tmp
# -- copy mode
# Copy Mode:
# prefix [ Enter copy mode to copy text or view the history.
# prefix ] Paste the most recently copied buffer of text.
# space Start selection.
# esc Clear selection.
# enter Copy selection.
# q Quit copy mode.
# Enable Vi mode.
set-option -g mode-keys vi
# Enter copy mode.
bind Enter copy-mode
run -b 'tmux bind -t vi-copy v begin-selection 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi v send -X begin-selection 2> /dev/null || true'
run -b 'tmux bind -t vi-copy C-v rectangle-toggle 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi C-v send -X rectangle-toggle 2> /dev/null || true'
run -b 'tmux bind -t vi-copy y copy-selection 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi y send -X copy-selection-and-cancel 2> /dev/null || true'
run -b 'tmux bind -t vi-copy Escape cancel 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi Escape send -X cancel 2> /dev/null || true'
run -b 'tmux bind -t vi-copy H start-of-line 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi H send -X start-of-line 2> /dev/null || true'
run -b 'tmux bind -t vi-copy L end-of-line 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi L send -X end-of-line 2> /dev/null || true'
# Copy to macOS clipboard.
if -b 'command -v pbcopy > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | pbcopy"'
if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | reattach-to-user-namespace pbcopy"'
# Paste from macOS clipboard.
if -b 'command -v pbpaste > /dev/null 2>&1' 'bind C-v run -b "tmux set-buffer \"$(pbcopy)\"; tmux paste-buffer"'
if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind C-v run -b "tmux set-buffer \"$(reattach-to-user-namespace pbpaste)\"; tmux paste-buffer"'
# Copy to X11 clipboard.
if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xsel -i -b"'
if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1"'
# Paste from X11 clipboard.
if -b 'command -v xsel > /dev/null 2>&1' 'bind C-v run -b "tmux set-buffer \"$(xsel -o -b clipboard)\"; tmux paste-buffer"'
if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1' 'bind C-v run -b "tmux set-buffer \"$(xclip -o -selection clipboard >/dev/null 2>&1)\"; tmux paste-buffer"'
# Copy to Windows clipboard.
if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | clip.exe"'
if -b '[ -c /dev/clipboard ]' 'bind y run -b "tmux save-buffer - > /dev/clipboard"'
# Paste from Windows clipboard.
if -b 'command -v clip.exe > /dev/null 2>&1' 'bind C-v run -b "tmux set-buffer clip.exe; tmux paste-buffer"'
if -b '[ -c /dev/clipboard ]' 'bind C-v run -b "tmux set-buffer /dev/clipboard; tmux paste-buffer"'
# -- buffers
bind b list-buffers # list paste buffers
bind p paste-buffer # paste from the top paste buffer
bind P choose-buffer # choose which buffer to paste from
bind L pipe-pane -o "cat >> /tmp/buffer.log" \; display-message "Toggled log to /tmp/buffer.log"
# Local Variables:
# outline-regexp: "# --"
# End: