-
Notifications
You must be signed in to change notification settings - Fork 6
/
.tmux.conf
281 lines (200 loc) · 10.1 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
# ~/.tmux.conf
# Copyright (C) 2021 Maciej Delmanowski <drybjed@gmail.com>
# SPDX-License-Identifier: GPL-3.0-only
# -- Environment --------------------------------------------------------{{{1
# Copy specified variables from the environment when a new tmux session is
# created or existing session is attached
set-option -g update-environment \
"DBUS_SESSION_BUS_ADDRESS \
DESKTOP_SESSION \
DISPLAY \
GNOME_KEYRING_CONTROL \
GNOME_KEYRING_PID \
GPG_AGENT_INFO \
ORIGCOLORTERM \
ORIGTERM \
SESSION_MANAGER \
SSH_AGENT_PID \
SSH_AUTH_SOCK \
SSH_CONNECTION \
WINDOWID \
XAUTHORITY \
XDG_SESSION_COOKIE \
XDG_SESSION_PATH"
# Set tmux version in the environment to be used by the version-specific
# commands
# Source: https://stackoverflow.com/questions/35016458/
run-shell 'tmux setenv -g TMUX_VERSION $(tmux -V | \
sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
# -- Keybindings --------------------------------------------------------{{{1
# Send prefix character into the client when pressed twice
bind-key ` send-prefix
bind-key C-b send-prefix
# Enable and disable custom prefix in case of paste issues
bind-key F7 set-option -g prefix C-b
bind-key F8 set-option -g prefix `
# <prefix> \ or v: split window vertically
bind-key \ split-window -h
bind-key v split-window -h
# <prefix> - or b: split window horizontally
bind-key - split-window -v
bind-key b split-window -v
# <prefix> i or o: select prev/next pane
bind-key i select-pane -t :.-
bind-key o select-pane -t :.+
# <prefix> vi motions: switch panes
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# <prefix> <Meta> + vi motions: resize panes
bind-key -r -T prefix M-h resize-pane -L 8
bind-key -r -T prefix M-j resize-pane -D 4
bind-key -r -T prefix M-k resize-pane -U 4
bind-key -r -T prefix M-l resize-pane -R 8
# <prefix> <Meta> + <Shift> + vi motions: resize panes more
bind-key -r -T prefix M-H resize-pane -L 32
bind-key -r -T prefix M-J resize-pane -D 16
bind-key -r -T prefix M-K resize-pane -U 16
bind-key -r -T prefix M-L resize-pane -R 32
# <Meta> + vi motions: switch panes
bind-key -n M-h select-pane -L
bind-key -n M-j select-pane -D
bind-key -n M-k select-pane -U
bind-key -n M-l select-pane -R
# <Meta> + <Shift> + vi motions: move panes spatially
bind-key -n M-H select-pane -L \; swap-pane -ds '!'
bind-key -n M-J select-pane -D \; swap-pane -ds '!'
bind-key -n M-K select-pane -U \; swap-pane -ds '!'
bind-key -n M-L select-pane -R \; swap-pane -ds '!'
# <Meta> + Left/Right: switch to left/right window
# (doesn't work on console)
bind-key -n M-Left previous-window
bind-key -n M-Right next-window
# <Meta> + , or .: switch to left/right window
# (doesn't work on console)
bind-key -n M-, previous-window
bind-key -n M-. next-window
# <Meta> + < or >: move current window left or right
# (doesn't work on console)
bind-key -n M-< swap-window -t -1
bind-key -n M-> swap-window -t +1
# <Meta> + /: enter copy or search mode
bind-key -n M-/ copy-mode
# <prefix> /: switch to the previous window
bind-key / last-window
# <Meta> + f: switch fullscreen mode of the current pane
bind-key -n M-f resize-pane -Z
# <prefix> r: reload tmux configuration file
bind-key r source-file ~/.tmux.conf
# https://zserge.com/posts/tmux/
# Linux system clipboard
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "xclip -in -selection clipboard"
# -- Options ------------------------------------------------------------{{{1
# Enable mouse mode on older tmux versions
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.1" | bc)" = 1 ]' " \
set -g mouse-select-pane on; set -g mode-mouse on; \
set -g mouse-resize-pane on; set -g mouse-select-window on"
# In version 2.1 "mouse" replaced the previous 4 mouse options
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.1" | bc)" = 1 ]' \
"set -g mouse on"
# UTF8 is autodetected in 2.2 onwards, but errors if explicitly set
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.2" | bc)" = 1 ]' \
"set -g utf8 on; set -g status-utf8 on; set -g mouse-utf8 on"
# Set the default tmux prefix character
set-option -g prefix `
# Use vi keyboard shortcuts by default
set-window-option -g mode-keys vi
# Set the start index of tmux windows, keeping it at 1 makes switching using
# M-<number> easier
set-option -g base-index 1
# Set the start of the pane index, to make it similar to the window index
set-option -g pane-base-index 1
# Renumber all windows when a window is closed
set-option -g renumber-windows on
# Don't wait after <Escape> is pressed to check if a meta-key is pressed
set-option -s escape-time 0
# Rename windows automatically if a custom name has not been set. The name will
# based on the current process name.
set-window-option -g automatic-rename on
set-window-option -g automatic-rename-format '#{pane_current_command}'
# Allow programs to rename windows via ANSI escape sequences
set-window-option -g allow-rename on
# Increase the scrollback size
set-option -g history-limit 65536
# Define the value of the $TERM environment variable
set-option -g default-terminal "screen-256color"
# -- Window/pane activity monitoring ------------------------------------{{{1
# Monitor windows and panes for activity
set-window-option -g monitor-activity on
# Monitor window and panes for bells (^G) sent by applications
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.6" | bc)" = 1 ]' \
"set-window-option -g monitor-bell on"
# Define which windows should create activity events
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.6" | bc)" = 1 ]' \
"set-option -g activity-action other"
# Define which windows should create bell events
set-option -g bell-action any
# Define custom window title style on activity
set-window-option -g window-status-activity-style fg='red,underscore'
# Define custom window title style on bell
set-window-option -g window-status-bell-style fg='red,underscore'
# -- X window title -----------------------------------------------------{{{1
# Try setting the X window title using ANSI sequences
set-option -g set-titles on
# The string that defines the X window title, used by default
set-option -g set-titles-string "`#S -- tmux"
# If a SSH session is detectd, use a more desciptive string as X window title
if-shell '[ -n "$SSH_CONNECTION" ]' 'set-option -g set-titles-string "ssh!#(whoami)@#H`#S -- tmux"'
# -- Messages, command line ---------------------------------------------{{{1
# Configure the style of tmux messages and the command prompt
set-option -g message-style fg='yellow,bold',bg='blue,bold'
# Set message display time in miliseconds
set-option -g display-time 2000
# -- Left status bar ----------------------------------------------------{{{1
# Set the maximum length of the left status bar
set-option -g status-left-length 50
# The default status, used in X window session
# `<session-name>
set-option -g status-left '#[fg=black,bold]--#[default] #[fg=yellow,bold]#[bg=blue,bold]#{?client_prefix,`#S#[default],#[fg=black,bold]#[bg=default]`#[fg=yellow,nobold]#S#[default]} #[fg=black,bold]--#[default] '
# Change the status on Linux console to show more relevant details
# <user>@<host>:<tty>`<session-name>
if-shell '[ -z "$DISPLAY" -a -z "$SSH_CONNECTION" ]' \
'set-option -g status-left "#[fg=black,bold]--#[default] #[fg=green]#(whoami)#[fg=black,bold]@#[default]#[fg=cyan]#H#[fg=black,bold]:#[fg=magenta,nobold]#{s|/dev/||:client_tty}#[fg=yellow,bold]#[bg=blue,bold]#{?client_prefix,`#S#[default],#[fg=black,bold]#[bg=default]`#[fg=yellow,nobold]#S#[default]} #[fg=black,bold]--#[default] "'
# Change the status when SSH connection is detected to show more relevant
# details
# ssh!<user>@<host>`<session-name>
if-shell '[ -n "$SSH_CONNECTION" ]' \
'set -g status-left "#[fg=black,bold]--#[default] #[fg=yellow,nobold]ssh#[fg=black,bold]!#[fg=green,nobold]#(whoami)#[fg=black,bold]@#[default]#[fg=cyan,bold]#H#[fg=yellow,bold]#[bg=blue,bold]#{?client_prefix,`#S#[default],#[fg=black,bold]#[bg=default]`#[fg=yellow,nobold]#S#[default]} #[fg=black,bold]--#[default] "'
# -- Middle status bar (window list) ------------------------------------{{{1
# Align the window list to the left
set-option -g status-justify left
# Configure the style of the middle status bar
set-option -g status-style fg='#999999',bg=default
# Set the style and format of the inactive windows
set -g window-status-format ' #[fg=magenta]#I#[fg=black,bold]:#[fg=white,nobold,dim]#W#[fg=green,nobold,nodim]#F '
set -g window-status-style fg='#777777',bg='default'
# Set the style and format of the currently active window
set -g window-status-current-format '#[fg=cyan,bold]╰╴#[fg=magenta,bold]#I#[fg=black,bold]:#[fg=white]#W#[fg=green,bold]#F#[fg=cyan,bold]╶╯'
set -g window-status-current-style fg='white,bold',bg='default'
# Use non-Unicode characters for the active window on Linux console
if-shell '[ -z "$DISPLAY" -a -z "$SSH_CONNECTION" ]' \
'set -g window-status-current-format "#[fg=cyan,bold]└─ #[fg=magenta,bold]#I#[fg=black,bold]:#[fg=white]#W#[fg=green,bold]#F#[fg=cyan,bold] ─┘"'
# -- Right status bar ---------------------------------------------------{{{1
# Display simple status bar in X window session
set -g status-right ' #[fg=black,bold]--'
# In Linux console or SSH session, show current load average and time
if-shell '[ -z "$DISPLAY" -o -n "$SSH_CONNECTION" ]' \
'set -g status-right " #[fg=black,bold]-- #[default]#[fg=yellow]#(cat /proc/loadavg | cut -d \" \" -f 1,2,3) #[fg=black,bold]-- #[fg=cyan,bright]%H:%M #[fg=black,bold]--"'
# -- Pane style ---------------------------------------------------------{{{1
# The style of the inactive pane border
set -g pane-border-style fg='#444444',bg=default
# The style of the active pane border
set -g pane-active-border-style fg='#888888',bg=default
# The style of the inactive pane border on Linux console
if-shell '[ -z "$DISPLAY" -a -z "$SSH_CONNECTION" ]' \
'set-option -g pane-border-style fg="brightblack",bg=default'
# The style of the active pane border on Linux console
if-shell '[ -z "$DISPLAY" -a -z "$SSH_CONNECTION" ]' \
'set-option -g pane-active-border-style fg="white",bg=default'