-
Notifications
You must be signed in to change notification settings - Fork 8
/
.tmux.conf
258 lines (214 loc) · 7.55 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
# .tmux.conf
# ===== Set options ===== {{{
# set-option (alias: set)
# -w: Window option.(equivalent to the set-window-option command)
# -s: Server option.
# -g: Global session or window option.
# -u: Unsets an option
# -o: Prevents setting an option that is already set.
# -q: Suppresses errors about unknown or ambiguous options.
# -a: If the option expects a string or a style, value is appended to the existing setting.
#
# * A session inherits the option from the global options
# (or with -g, restores a global option to the default).
set-option -s escape-time 0
set-window-option -g xterm-keys on
set-window-option -g mode-keys vi
set-window-option -g automatic-rename on
# Update the TERM variable of terminal emulator when creating a new session or attaching a existing session.
set-option -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM'
# Determine if we should enable 256-colour support.
if "[[ ${TERM} =~ 256color || ${TERM} == fbterm ]]" 'set-option -g default-terminal screen-256color'
if "[[ ${TERM} =~ 256color || ${TERM} == fbterm ]]" 'set-option -g terminal-overrides "xterm:colors=256"'
set-option -g set-titles on
set-option -g base-index 1
set-option -g pane-base-index 1
set-option -g renumber-windows on
set-option -g history-limit 10000
set-option -g display-panes-time 1500
set-option -g display-time 1500
set-option -g monitor-activity on
set-option -g visual-activity on
# set-option -g alternate-screen off
# set-option -g set-clipboard off
# Mouse.
# set-option -g mouse on
# set-option -g mouse-select-window on
# set-option -g mouse-select-pane on
# set-window-option -g mode-mouse on
# Bell.
set-option -g bell-action none
set-option -g bell-on-alert on
set-option -g visual-bell on
# Screensaver.
set-option -g lock-after-time 3600
set-option -g lock-command 'cmatrix -s -b'
# }}}
# ===== Status line ===== {{{
set-option -g status on
set-option -g status-interval 5
set-option -g status-position bottom
set-option -g status-justify left
# Color:
# black, red, green, yellow, blue, magenta, cyan, white
# brightblack, brightred, ..., brightxxxxx
# Reference example to set colors:
# - https://github.com/seebi/tmux-colors-solarized
# Statusbar colors.
set-option -g status-bg colour235
set-option -g status-fg colour136
set-option -g status-attr default
# Window title colors.
set-window-option -g window-status-fg colour244
set-window-option -g window-status-bg default
# set-window-option -g window-status-attr dim
# Active window title colors.
set-window-option -g window-status-current-fg colour166
set-window-option -g window-status-current-bg default
# set-window-option -g window-status-current-attr bright
# Pane border.
set-option -g pane-border-fg colour235
set-option -g pane-active-border-fg colour240
# Active pane border.
# set -g pane-active-border-fg brightgreen
# set -g pane-active-border-bg black
# Message text.
set-option -g message-bg colour235
set-option -g message-fg colour166
# Pane number display.
set-option -g display-panes-active-colour colour33
set-option -g display-panes-colour colour166
# Copy mode colors.
set-window-option -g mode-fg black
set-window-option -g mode-bg white
# Clock.
set-window-option -g clock-mode-colour colour64
# }}}
# ===== Right/Left Status line ===== {{{
# Character pair Replaced with.
# #(shell-command) First line of the command's output.
# #[attributes] Colour or attribute change.
# #H Hostname of local host.
# #h Hostname of local host without the domain name.
# #F Current window flag.
# #I Current window index.
# #D Current pane unique identifier.
# #P Current pane index.
# #S Session name.
# #T Current pane title.
# #W Current window name.
# ## A literal `#'.
#
# Date
# #y year (last 2 digits)
# #m month
# #d day
# #H hour (from 0 to 24)
# #M minutes
# #S seconds
# Left.
set -g status-left ' #[fg=white,bold]#I-#P#[default] > #[fg=white,bold]#(whoami)@#H#[default] >'
set -g status-left-length 40
# Right.
set -g status-right '< #[fg=white]#(echo $LANG)#[default] < #[fg=red,bold]%Y/%m/%d(%a) %H:%M:%S#[default] '
set -g status-right-length 50
# tmux-powerline.
# Left.
if -b 'test -f ~/.tmux/tmux-powerline/powerline.sh' 'set-option -g status-left-length 100'
if -b 'test -f ~/.tmux/tmux-powerline/powerline.sh' 'set-option -g status-left "#(~/.tmux/tmux-powerline/powerline.sh left)"'
# Right.
if -b 'test -f ~/.tmux/tmux-powerline/powerline.sh' 'set-option -g status-right-length 100'
if -b 'test -f ~/.tmux/tmux-powerline/powerline.sh' 'set-option -g status-right "#(~/.tmux/tmux-powerline/powerline.sh right)"'
# }}}
# ===== Key bind ===== {{{
#
# List keys : <prefix>?
# List keys -t vi-copy : <prefix>/
# Prefix.
unbind C-b
unbind C-o
set-option -g prefix C-o
bind o send-prefix
bind r source-file ~/.tmux.conf \; display-message 'Reload Config!!'
bind / list-keys -t vi-copy
bind R refresh-client
bind * list-clients
bind d detach
# Window.
bind c new-window
bind w choose-window
bind h previous-window
bind j previous-window
bind k next-window
bind l next-window
bind -r Space next-window
bind C-o run 'tmux last-pane || tmux last-window'
bind ^a last-window
bind s split-window -v
bind v split-window -h
bind A command-prompt -I '#W' 'rename-window %%'
bind ^q confirm-before -p 'kill-window #W? (y/n)' kill-window
bind \ confirm-before -p 'kill-server? (y/n)' kill-server
# Select pane.
bind -r Tab select-pane -t :.+
bind -r BTab select-pane -t :.-
bind ^h select-pane -L
bind ^j select-pane -D
bind ^k select-pane -U
bind ^l select-pane -R
# Resize pane.
bind -r H resize-pane -L 6
bind -r J resize-pane -D 6
bind -r K resize-pane -U 6
bind -r L resize-pane -R 6
bind b break-pane
# Join Pane
# Move the current pane to specified position. (-t: target)
# :join-pane -h -t [session]:[window].[pane]
# Move the specified pane to current window with. (-s: source)
# :join-pane -v -t -s :1.2
# * -h: Horizontal split.
# * -v; Vertical split
# Copy-mode.
bind ^y copy-mode \; display-message '* Copy Mode *'
bind -r ^"[" copy-mode
bind y run-shell 'tmux-pbcopy'
bind p paste-buffer
bind -r ^] paste-buffer
# Copy a line.
bind-key -t vi-copy Y copy-line
# Rectangle copy mode.
bind-key -t vi-copy C-v rectangle-toggle
# Move to start/end of line like emacs.
bind-key -t vi-copy C-a start-of-line
bind-key -t vi-copy C-e end-of-line
# Move to top/bottom line like vim.
bind-key -t vi-copy g top-line
bind-key -t vi-copy C-g history-top
bind-key -t vi-copy G bottom-line
# Setup 'v' to begin selection as in Vim.
# bind-key -t vi-copy v begin-selection
# bind-key -t vi-copy y copy-pipe 'tmux-pbcopy'
# Update default binding of `Enter` to also use copy-pipe.
# unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe 'tmux-pbcopy'
# percol.
bind b split-window "tmux lsw | percol --initial-index $(tmux lsw | awk '/active.$/ {print NR-1}') | cut -d':' -f 1 | xargs tmux select-window -t"
bind B split-window "tmux ls | percol --initial-index $(tmux ls | awk '/attached.$/ {print NR-1}') | cut -d':' -f 1 | xargs tmux switch-client -t"
# Unbind keys.
# suspend client
unbind ^z
# break-pane
unbind !
# split-window
unbind "\""
# split-window -h
unbind %
# kill-window
unbind &
# zsh pbcopy.(Mac only)
# set-option -g default-command 'type reattach-to-user-namespace > /dev/null 2>&1 && reattach-to-user-namespace -l zsh || $SHELL'
# }}}
# ===== tmux-ressurect ===== {{{
if -b 'test -f ~/.tmux/tmux-resurrect/resurrect.tmux' 'run-shell ~/.tmux/tmux-resurrect/resurrect.tmux'
# }}}