-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
229 lines (160 loc) · 7 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
# I generally try to avoid explicitly changing the default keybindings so that
# I'm not completely up a creek when I need to use an unfamiliar machine.
# Otherwise the following is a collection of settings that I've tested and
# found useful. Some broken or less-useful ones are left commented out for
# reference.
# Prefix settings
# I don't mind C-b, but some people prefer remapping the prefix. Apparently vim
# uses C-b, but I never use this.
# Remap prefix from C-b to C-a
#unbind C-b
#set-option -g prefix C-a
#bind-key C-a send-prefix
# Restore original prefix key
#unbind C-a
#set-option -g prefix C-b
#bind-key C-b send-prefix
# Terminal settings
# Use color terminal (tmux > 2.1)
# This seems to break mouse support when using some older versions of vim. It's
# not enough for our system to have a new, properly configured vim, any machine
# that we might ssh into also needs to have a newer vim, as this property is
# inherited as the $TERM variable over ssh.
set-option -g default-terminal "tmux-256color"
# Use color terminal (tmux < 2.1)
#set-option -g default-terminal "screen-256color"
# Use 24-bit color (tmux > 2.2)
set-option -ga terminal-overrides ",xterm*:Tc"
set-option -ga terminal-overrides ",alacritty*:Tc"
# Fix PgUp/PgDn scrolling
# This breaks scrollwheel scrolling in programs like less/man when mouse mode
# is off (strangely, scrollwheel scrolling doesn't seem to work at all when
# mouse mode is on).
#
# Disable use of the "alternate screen" so I can use the terminal's scrollback
set-option -ga terminal-overrides ",xterm*:smcup@:rmcup@"
#
# This is supposed to do something similar, but I haven't figured out how it
# works.
#set-option -g alternate-screen off
# Use xterm-style function key sequences. This breaks programs that are not
# expecting xterm-style function key sequences, and can be particularly nasty
# when using tmux* or screen* as your $TERM, since many of programs that *do*
# accept xterm-style function key sequences reasonably only expect them when
# your $TERM is xterm*. Sigh.
#
# I usually just change $TERM whenever I encounter this and can't easily modify
# the program to check $TERM for screen or tmux, but it's sort of a pain, and
# there's probably a better way to do it.
set-option -g xterm-keys on
# Mouse settings
# Enable mouse (tmux > 2.1)
set-option -gq mouse on
# Enable mouse (tmux < 2.1)
#set-window-option -gq mode-mouse on
#set-option -gq mouse-select-window on
#set-option -gq mouse-select-pane on
#set-option -gq mouse-resize-pane on
# Fix scrollwheel in less/man (wtf...)
# http://sc0ty.pl/2015/12/reasonable-mouse-support-in-tmux/
# https://github.com/sc0ty/config/blob/master/.tmux.conf
bind-key -n WheelUpPane \
if-shell -Ft= "#{?pane_active,0,1}" "select-pane -t=" \; \
if-shell -Ft= "#{pane_in_mode}" \
"send-keys -M ; send-keys -M ; send-keys -M" \
"if-shell -Ft= \"#{mouse_any_flag}\" \
\"send-keys -M\" \
\"if-shell -Ft= '#{alternate_on}' \
'send-keys Up Up Up' \
'copy-mode -e'\""
bind-key -n WheelDownPane \
if-shell -Ft= "#{?pane_active,0,1}" "select-pane -t=" \; \
if-shell -Ft= "#{pane_in_mode}" \
"send-keys -M ; send-keys -M ; send-keys -M" \
"if-shell -Ft= \"#{mouse_any_flag}\" \
\"send-keys -M\" \
\"if-shell -Ft= '#{alternate_on}' \
'send-keys Down Down Down'\""
# UI settings
# start counting windows from 1
set-option -g base-index 1
# start counting panes from 1
set-option -g pane-base-index 1
# Renumber windows on window close
set-option -g renumber-windows on
# open new window in current directory
bind-key c new-window -c '#{pane_current_path}'
# open new panes in current directory
bind-key '"' split-window -c '#{pane_current_path}'
bind-key % split-window -h -c '#{pane_current_path}'
# don't rename windows automatically (use this option to remember manually set
# window names). I haven't found this to be necessary when automatic-rename is
# working.
#set-option -g allow-rename off
# Enable window monitoring
set-option -g monitor-activity on
#set-option -g visual-activity on
# Update the status line more frequently
set-option -g status-interval 1
# Show indicators and results for long enough to actually read them
set-option -g display-time 2000
# Default half-second escape delay is ridiculous
set-option -g escape-time 0
# Note that `=` is shorthand for `{mouse}`
# Double click on status line for new window
# tmux > 2.3
bind-key -n DoubleClick1Status new-window -a -t= -c '#{pane_current_path}'
# Drag and drop to reorder windows on status line
bind-key -n MouseDrag1Status swap-window -t=
# Join pane interactively
bind-key @ choose-window "join-pane -b -s '%%'"
# Clipboard settings
# Use vi style keybindings in copy mode
set-option -g mode-keys vi
# TODO: Test copy/paste stuff on local and remote sessions
# I haven't figured out what this actually does.
#set-option -g set-clipboard on
#set-option -ga terminal-overrides ",xterm*:Ms"
# I tried to define copy behavior using hooks, but this doesn't work yet
# https://github.com/tmux/tmux/issues/691
# It's also difficult / impossible to get a list of legal hook names, which
# makes debugging this kind of annoying.
#set-hook -g after-copy-selection-and-cancel "run-shell 'tmux show-buffer | xsel -i -b'"
# Copy to system clipboard when we deliberately copy
# tmux > 2.3
bind-key -T copy-mode-vi Enter send-keys -X copy-selection-and-cancel \;\
run-shell "tmux show-buffer | xsel -i -b"
# tmux < 2.3
#bind-key -t vi-copy Enter copy-pipe "xsel -i -b"
# Copy to middle-click clipboard when highlighting with mouse
# tmux > 2.3
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection-and-cancel \;\
run-shell "tmux show-buffer | xsel -i -p"
# Copy from system clipboard into tmux paste buffer
bind-key v run-shell "xsel -o -b | tmux load-buffer -"
# Copy from system clipboard into tmux paste buffer, and paste into window
bind-key C-v run-shell "xsel -o -b | tmux load-buffer - ; tmux paste-buffer"
# Other settings
# Request focus events from terminal, if supported (haven't tested this)
set-option -g focus-events on
# Resize to smallest connected terminal by window rather than by session.
set-option -g aggressive-resize on
# Increase scrollback buffer size
set-option -g history-limit 10000
# Keep tmux history
#set-option -g history-file "~/.tmux_history"
# Visual settings
# Use tmux titles as terminal emulator titles
set-option -g set-titles on
set-option -g set-titles-string "#T"
# I don't really need a clock
set-option -g status-right " #{=38:pane_title} "
#set-option -g status-right-length 40
# Status bar
set-option -g status-position top
set-option -g status-style "fg=#FFFFFF,bg=#335577"
set-option -g status-right-style "fg=#FFFFFF,bg=#446688"
# I want contrast between messages / command mode and the status line.
# Still need to find a nicer color scheme...
#set-option -g message-style "fg=#FFFFFF,bg=#446688"
set-option -g pane-active-border-style "fg=#335577"