-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path.tmux.conf
255 lines (219 loc) · 9.49 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
# netj's .tmux.conf
# Author: Jaeho Shin <[email protected]>
# Created: 2010-12-26
# C-t as prefix
set-option -g prefix C-t
unbind C-t
bind C-t last-window
unbind t
bind t send-prefix
unbind C-b
# toggle prefix suitable for (double-decker) tmux in tmux windows
bind-key -n C-M-t \
if-shell "[ \"`tmux show-options prefix`\" = 'prefix C-t' ]" \
"set-option prefix C-s; unbind -n M-Up; unbind -n M-PageUp" \
"set-option prefix C-t; bind -n M-Up copy-mode; bind -n M-PageUp copy-mode" \
#
# quicker access to frequently used prefix combos
# quick select last window
bind-key -n C-M-a select-window -l
# quick toggle zoom pane
bind-key -n C-M-z resize-pane -Z
## shorthands
tmux_version_is_less_than="test `tmux -V | cut -d' ' -f2` \\< "
## easy/uniform copy mode
# See also: https://medium.freecodecamp.org/tmux-in-practice-scrollback-buffer-47d5ffa71c93
# trigger copy mode by
bind -n M-Up copy-mode
bind -n M-PageUp copy-mode
# Scroll up/down by 1 line, half screen, whole screen
if-shell "! $tmux_version_is_less_than 2.4" "\
bind -T copy-mode M-Up send-keys -X scroll-up ;\
bind -T copy-mode M-Down send-keys -X scroll-down ;\
bind -T copy-mode M-PageUp send-keys -X halfpage-up ;\
bind -T copy-mode M-PageDown send-keys -X halfpage-down;\
bind -T copy-mode PageUp send-keys -X page-up ;\
bind -T copy-mode PageDown send-keys -X page-down ;\
"
# UTF-8 (necessary up to 2.1)
if-shell "$tmux_version_is_less_than 2.2" "\
set-option -g status-utf8 on ;\
set-window-option -g utf8 on ;\
"
# status and title format
set-option -g set-titles-string "#T - #I:#W#F#S^#h"
set-option -g status-justify right
set-option -g status-left "#T"
set-option -g status-left-length 48
set-option -g status-right "#[fg=white,bright]#S#[default]^#[fg=white]#h#[default]"
set-option -g status-right-length 16
# 256 color: XXX tmux should be launched with option -2.
set-option -g default-terminal "screen-256color"
# You can check 256 color support with this command:
# curl http://www.frexx.de/xterm-256-notes/data/256colors2.pl | perl
# status colours
if-shell "$tmux_version_is_less_than 2.9a" "\
set-option -g status-bg black ;\
set-option -g status-fg default ;\
set-option -g status-fg brightblack ;\
set-option -g status-attr none ;\
set-window-option -g window-status-fg brightblack ;\
set-window-option -g window-status-attr none ;\
set-option -g status-left-fg green ;\
set-option -g status-left-attr bright ;\
set-window-option -g window-status-current-fg green ;\
set-window-option -g window-status-current-attr bright ;\
set-window-option -g window-status-activity-fg yellow ;\
set-window-option -g window-status-activity-attr bright ;\
set-window-option -g window-status-bell-fg red ;\
set-window-option -g window-status-bell-attr bright ;\
" "\
set-option -g status-style bg=black ;\
set-option -ga status-style fg=brightblack ;\
set-option -g status-left-style fg=green,bright ;\
set-window-option -g window-status-style fg=brightblack ;\
set-window-option -g window-status-current-style fg=green,bright ;\
set-window-option -g window-status-activity-style fg=yellow,bright ;\
set-window-option -g window-status-bell-style fg=red,bright ;\
"
# some more options
set-option -g base-index 1
set-option -g set-titles on
set-option -g display-time 2500
set-option -g history-limit 10000000
set-option -g status-keys vi
set-window-option -g mode-keys vi
set-window-option -g monitor-activity on
set-window-option -g clock-mode-style 24
set-window-option -g wrap-search off
## mouse options
# mouse options changed since in 2.1 with some bugs not auto starting
# See: https://github.com/tmux/tmux/issues/145
if-shell "! $tmux_version_is_less_than 2.1" "\
set-window-option -g mouse on ;\
bind -n WheelUpPane \
if-shell -F -t= \"#{mouse_any_flag}\" \
\"send-keys -M\" \
\"if -Ft= '#{pane_in_mode}' \
'send-keys -M' \
'select-pane -t=; copy-mode -e; send-keys -M'\" ;\
bind -n WheelDownPane \
select-pane -t=\\; send-keys -M ;\
"
# mouse options up to 2.0
if-shell "$tmux_version_is_less_than 2.1" "\
set-window-option -g mode-mouse on ;\
set-window-option -g mouse-select-window on ;\
set-window-option -g mouse-select-pane on ;\
set-window-option -g mouse-resize-pane on ;\
set-window-option -g mouse-utf8 on ;\
"
# XXX Disabling this for somehow breaking tmux's set-titles option
# ("mode-mouse on" with MouseTerm saved me though)
# allow buffer scrolling also for xterm-likes
# See: https://bbs.archlinux.org/viewtopic.php?id=102217
# See: http://superuser.com/questions/210125/scroll-shell-output-with-mouse-in-tmux/300716#300716
#set -g terminal-overrides 'xterm*:smcup@:rmcup@'
### Key Bindings
## Some easier ones GNU Screen style key bindings, which I'm pretty used to
# window
unbind ^C
bind ^C new-window
unbind c
bind c new-window
# session
unbind S
bind S new-session
unbind ^S
bind ^S switch-client -l
# break window into new session
unbind @
#bind @ command-prompt -I "1" -p "(break window to new-session)" "new-session -d -n'moving' -s'%1' 'sleep 1'; swap-window -t'%1:moving'; switch-client -t'%1:'"
bind @ split-window -d -h -l0 \
'n=$(tmux list-sessions -F "#S" | grep "^[0-9]\\+$" | sort -nr | head -n 1); let n++; \
tmux command-prompt -I "$n" -p "(break window into new session)" \
"new-session -d -s\"%1\" -n moving \"sleep 1\"; swap-window -t\"%1:moving\"; switch-client -t\"%1:\""'
# detach
unbind ^D
bind ^D detach
# make this client the only one by detaching all other clients
unbind O
bind O attach-session -d
# next ^@ ^N sp n
unbind ^N
bind ^N next-window
unbind n
bind n next-window
unbind C-Space
bind C-Space next-window
# prev ^H ^P p ^?
unbind ^P
bind ^P previous-window
unbind p
bind p previous-window
unbind Space
bind Space previous-window
# windows ^W w
unbind ^W
bind ^W choose-window
# redisplay ^L
unbind ^L
bind ^L refresh-client
# reload config
unbind ^R
bind ^R source ~/.tmux.conf
# record window
bind-key | pipe-pane -o 'cat >>~/tmux-#S.#I.#P.log'
# toggle activity/silence monitoring
bind M setw monitor-activity on\; setw monitor-silence 0
bind m command-prompt -p "monitor-silence (seconds)" "setw monitor-activity off; setw monitor-silence %%"
## vim style key bindings
# move around panes with j and k, a bit like vim
unbind l
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# resize panes like vim
bind < resize-pane -L 1
bind > resize-pane -R 1
bind - resize-pane -D 1
bind + resize-pane -U 1
## key bindings compatible with my Emacs config
unbind Tab
bind Tab select-pane -t :.+
bind C-o select-pane -t :.-
unbind "\""; bind "\"" split-window -v
unbind % ; bind % split-window -h
# put split pane left/top of the current one, just like vim (-b supported since 2.0)
# FIXME make below less ugly
if-shell "! $tmux_version_is_less_than 2.0" "\
unbind % ; bind % split-window -h -b ;\
unbind \"\\\"\"; bind \"\\\"\" split-window -v -b ;\
"
## Vim and Tmux better together: https://blog.bugsnag.com/tmux-and-vim/
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
# quicker vim-like split
bind-key -n C-M-v if-shell "$is_vim" "send-keys C-\\ C-o C-M-v" "split-window -h"
bind-key -n C-M-s if-shell "$is_vim" "send-keys C-\\ C-o C-w s" "split-window -v"
# XXX ugliness below is inevitable for tmux >= 2.0
if-shell "! $tmux_version_is_less_than 2.0" "\
bind-key -n C-M-v if-shell \"\$is_vim\" \"send-keys C-\\\\ C-o C-M-v\" \"split-window -h -b\" ;\
bind-key -n C-M-s if-shell \"\$is_vim\" \"send-keys C-\\\\ C-o C-w s\" \"split-window -v -b\" ;\
"
# uniform vim-tmux-navigation with Ctrl+Alt+h/j/k/l
bind-key -n C-M-h if-shell "$is_vim" "send-keys C-\\ C-o C-M-h" "select-pane -L"
bind-key -n C-M-j if-shell "$is_vim" "send-keys C-\\ C-o C-M-j" "select-pane -D"
bind-key -n C-M-k if-shell "$is_vim" "send-keys C-\\ C-o C-M-k" "select-pane -U"
bind-key -n C-M-l if-shell "$is_vim" "send-keys C-\\ C-o C-M-l" "select-pane -R"
bind-key -n C-M-\\ if-shell "$is_vim" "send-keys C-\\ C-o C-M-\\" "select-pane -l"
# vimux
bind-key -n C-M-m if-shell "$is_vim" "send-keys C-\\ C-o C-M-m" "send-keys C-M-m"
bind-key -n C-M-] if-shell "$is_vim" "send-keys C-\\ C-o C-M-]" "send-keys C-M-]"
bind-key -n C-M-[ if-shell "$is_vim" "send-keys C-\\ C-o C-M-[" "send-keys C-M-["
# Mac-specific settings
if-shell "type reattach-to-user-namespace" 'set-option -g default-command "reattach-to-user-namespace -l env SHLVL=0 bash -l"'
if-shell "! type reattach-to-user-namespace" 'set-option -g default-command "env SHLVL=0 bash -l"'
# local config
if-shell "[ -e ~/.tmux_local ]" "source-file ~/.tmux_local"