-
Notifications
You must be signed in to change notification settings - Fork 13
/
tmux.conf
315 lines (257 loc) · 9.89 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
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
# _
# | |_ _ __ ___ _ ___ __
# | __| '_ ` _ \| | | \ \/ /
# | |_| | | | | | |_| |> <
# \__|_| |_| |_|\__,_/_/\_\ ver 2.1
#
# written by Shotaro Fujimoto (https://github.com/ssh0)
#------------------------------------------------------------------------------
# General settings {{{
#------------------------------------------------------------------------------
# enable utf-8
# setw -g utf8 on
# max history limit
set -g history-limit 5000
# escape time
set -s escape-time 0
# Set the time in milliseconds for which the indicators shown by the
# display-pane command appear.
set -g display-panes-time 3000
# count windows stating with 1 instead of 0
set -g base-index 1
set -g pane-base-index 1
# renumber the windows
set -g renumber-windows on
# Automatically set window title
setw -g automatic-rename on
#---------------------------------------------------------------------------}}}
# Keybind Documentation {{{
#------------------------------------------------------------------------------
# I prefered using Alt key instead "Prefix + something".
# And I'm using xmonad, so these key-bindings are similar to xmonad's one.
# My xmonad config is here:
# https://github.com/ssh0/dotfiles/blob/master/.xmonad/ssh0-home/xmonad.hs
#
# Prefix key: ^g
#
# Abbreviation:
# - [key]
# - (key) <- with Alt (or in MacOS, Command key)
#
# Structure in one session:
#
# +----------------+
# | (←,→,h,l) ↓(num) OR click status bar ↓ (Enter)
# window1 <------> window2 window3 window4
# ===============================================================
# pane1 pane1 pane1 pane1
# ↕ (j,k)
# pane2 + - - pane2 - - - -> (pane2)
# | (L)
# (pane3) <- + pane3
# (H) ↓ (c) ↓ (C)
# x x
#
#
# In a window:
#
# +---------------+------------+
# |pane1 |pane3 |
# | | |
# | | |
# +---------------+ |
# |pane2 | |
# | | |
# | | |
# +---------------+------------+
#
# split pane:
# - vertically : (|)
# - horizontally : (-)
# select pane : (j),(k) OR click the pane with mouse
# shift pane : (J),(K)
# kill pane : (c)
# change layout : (Space)
# fullscreen : (f)
# resize pane:
# (a)
# ↑
# (,) ← + → (.)
# ↓ OR drag pane-border with mouse
# (z)
# join to another window : (H),(L)
# join to another window : [Alt+Shift+num]
#---------------------------------------------------------------------------}}}
# Unbind all keys & default key settings {{{
#------------------------------------------------------------------------------
unbind-key -a
# default key-bindings {{{
#======================#
bind-key C-z suspend-client
bind-key ! break-pane
bind-key '#' list-buffers
bind-key '$' command-prompt "rename-session '%%'"
bind-key , command-prompt "rename-window '%%'"
bind-key - delete-buffer
bind-key . command-prompt "move-window -t '%%'"
bind-key : command-prompt
bind-key \; last-pane
bind-key = choose-buffer
bind-key ? list-keys
bind-key D choose-client
bind-key L switch-client -l
bind-key [ copy-mode
bind-key ] paste-buffer
bind-key d detach-client
bind-key f command-prompt "find-window '%%'"
bind-key i display-message
bind-key q display-panes
bind-key s choose-session
bind-key w choose-window
bind-key "~" show-messages
bind-key PPage copy-mode -u
bind-key -r M-1 select-layout even-horizontal
bind-key -r M-2 select-layout even-vertical
bind-key -r M-3 select-layout main-horizontal
bind-key -r M-4 select-layout main-vertical
bind-key -r M-5 select-layout tiled
# }}}
#---------------------------------------------------------------------------}}}
# Keybind (normal mode) {{{
#------------------------------------------------------------------------------
# prefix key ^b -> ^g
set -g prefix C-g
bind-key C-g send-prefix
# vi like key binding
setw -g mode-keys vi
bind-key -T vi-copy v begin-selection
# if session has > 1 windows in current, kill-pane without confirmation.
# But confirm before killing pane when it is the last pane in the window.
bind-key -n M-c if "tmux display -p \"#{window_panes}\" | grep ^1\$" \
"confirm-before -p \"Kill the only pane in the window? It will kill this window too. (y/N)\" kill-pane" \
"kill-pane"
# if session has > 1 windows in current, kill-window without confirmation.
# But confirm before killing window when it is the last window in the session.
bind-key -n M-C if "tmux display -p \"#{session_windows}\" | grep ^1\$"\
"confirm-before -p \"Kill the only window in this session? It will kill the session too. (y/N)\" kill-window" \
"kill-window"
# split window (easily remember)
bind-key -n M-- split-window -v -c "#{pane_current_path}"
bind-key -n M-| split-window -h -c "#{pane_current_path}"
# vim like
bind-key s split-window -v -c "#{pane_current_path}"
bind-key v split-window -h -c "#{pane_current_path}"
# move between panes
bind-key -n M-j select-pane -D
bind-key -n M-k select-pane -U
bind-key -n M-h select-pane -L
bind-key -n M-l select-pane -R
bind-key -n M-Down select-pane -t :.+
bind-key -n M-Up select-pane -t :.-
# select the master pane
bind-key -n M-m select-pane -t :.1
# swap pane
bind-key -n M-J swap-pane -D
bind-key -n M-K swap-pane -U
bind-key -n M-S-Down swap-pane -D
bind-key -n M-S-Up swap-pane -U
# move the pane to the master pane
bind-key -n M-M swap-pane -d -t :.1
# swap pane to Alt+shift+number
bind-key -n M-! join-pane -t :1
bind-key -n M-'"' join-pane -t :2
bind-key -n M-'#' join-pane -t :3
bind-key -n M-'$' join-pane -t :4
bind-key -n M-% join-pane -t :5
bind-key -n M-& join-pane -t :6
bind-key -n M-"'" join-pane -t :7
bind-key -n M-( join-pane -t :8
bind-key -n M-) join-pane -t :9
# resize panes (xmonad like)
bind-key -n M-',' resize-pane -L 1
bind-key -n M-z resize-pane -D 1
bind-key -n M-a resize-pane -U 1
bind-key -n M-'.' resize-pane -R 1
# maximize pane ("f"ull screen)
bind-key -n M-f resize-pane -Z
# display-panes
bind-key -n M-q display-panes
# move between window
bind-key -n M-Right next-window
bind-key -n M-Left previous-window
# swap window
bind-key -n M-S-Right swap-window -t :+
bind-key -n M-S-Left swap-window -t :-
# next layout
bind-key -n M-Space next-layout
# switch windows Alt+number
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
# select-window by name typing
bind-key W command-prompt "select-window -t '%%'"
# create new window
bind-key -n M-Enter new-window -c "#{pane_current_path}"
# choose-tree
bind-key t choose-tree
# Capture pane and open in Vim
bind-key C-c run 'tmux capture-pane -S -10240 -p > /tmp/tmux-capture.txt'\;\
new-window "vim + /tmp/tmux-capture.txt"
# Toggle status bar
bind-key -n F11 set status
# ^b + r => reload config file
bind-key r source-file ~/.tmux.conf \; display "Reloaded!"
#---------------------------------------------------------------------------}}}
# Keybind (copy mode) {{{
#------------------------------------------------------------------------------
# v: select start with v (default Space)
bind-key -T vi-copy v begin-selection
# V: select line
bind-key -T vi-copy V select-line
# C-v: select rectangular
bind-key -T vi-copy C-v rectangle-toggle
# y: yank
bind-key -T vi-copy y copy-selection
# Y: yank line
bind-key -T vi-copy Y copy-line
#---------------------------------------------------------------------------}}}
# Mouse settings {{{
#------------------------------------------------------------------------------
set -g mouse on
#---------------------------------------------------------------------------}}}
# Color {{{
#------------------------------------------------------------------------------
# use 256colors
set -g default-terminal screen-256color
# pane border
set -g pane-active-border-style fg="colour197"
set -g pane-active-border-style bg="colour234"
set -g pane-border-style fg="colour239"
set -g pane-border-style bg="colour234"
# window list
setw -g window-status-style fg="white"
setw -g window-status-style bg="colour235"
setw -g window-status-style attr="dim"
# message line
set -g message-style fg="white"
set -g message-style bg="colour235"
set -g message-style attr="bright"
#---------------------------------------------------------------------------}}}
# WM window title {{{
#------------------------------------------------------------------------------
# enable wm window titles
set -g set-titles on
# wm window title string (uses status bar variables)
set -g set-titles-string "#S - #W [#I/#{session_windows}] (#P/#{window_panes})"
#---------------------------------------------------------------------------}}}
# Status line {{{
#------------------------------------------------------------------------------
# source $HOME/.config/tmux/status_powerline.conf
source $HOME/.config/tmux/status.conf
#---------------------------------------------------------------------------}}}