-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmux.conf
More file actions
216 lines (147 loc) · 7.5 KB
/
tmux.conf
File metadata and controls
216 lines (147 loc) · 7.5 KB
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
start-server
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# TMUX devs often break compatibility with new releases, grumble, grumble
# see https://stackoverflow.com/questions/35016458/
run-shell 'tmux setenv -g TMUX_VERSION $(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
# conditional includes, based on version numbers
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.9" | bc)" = 1 ]' \
"source-file .tmux_colors_v2.8-" \
"source-file .tmux_colors_v2.9+"
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# use CTRL-A for the command key
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
# same thing, different syntax
#set-option -g prefix C-a
#unbind-key C-b
#bind-key C-a send-prefix
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# COLORS
# to get 256 colors to work on Linux
### set-option -g default-terminal "screen-256color" <-- screen or xterm ??
set-option -g default-terminal "xterm-256color"
# NOTE: attributes = bright (or bold), dim, underscore, blink, reverse, hidden, or italics
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# -- SESSION --
# session key bindings
# $ = rename session
# s = select from a menu of sessions
# -- WINDOWS --
set-option -g base-index 1
# window key bindings
# , = rename window
# re-ordering windows (see http://superuser.com/questions/343572/how-do-i-reorder-tmux-windows)
# re-order windows WITHOUT ctrl-A prefix
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
# re-order windows WITH ctrl-A prefix
bind-key P swap-window -t -1
bind-key N swap-window -t +1
# -- PANES --
set-window-option -g pane-base-index 1
# pane key bindings
bind-key < resize-pane -U 1
bind-key > resize-pane -D 1
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# STATUS BAR
# status bar - set text for current window tab (ctrl-A ,)
# printf '\033kNAMEHERE\033\\'
set-option -g status on
if-shell "if [[ $OSTYPE == 'linux'* ]] ; then true ; else false ; fi" \
'set-option -g status-utf8 on' # mac complains about utf8
set-option -g status-left-length 30
set-option -g status-left '#[fg=yellow,bright]#h#[fg=black,dim]:#[fg=cyan,bright]#S #[default]'
set-option -g status-right '#[fg=green,bright]%Y-%m-%d #[fg=white,bright]%l:%M%P#[default] '
# status bar - current window
set-window-option -g window-status-current-format "[#I#F#W]"
# status bar - non-current windows
set-window-option -g window-status-format "[#I#F#W]"
# status bar - non-current windows with activity
set-window-option -g monitor-activity on
#set-option -g visual-activity on
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# TITLES - shown in terminal tab
set-option -g set-titles off
## set-option -g set-titles-string '#H:#S.#I.#P #W #T' # window number,program name,active (or not)
set-option -g set-titles-string '#I : #T' # #T = current pane title (set by bash_prompt)
# window name shows current task - turn off
set-window-option -g automatic-rename off
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# NAVIGATION
# Smart pane switching with awareness of vim splits
# see https://github.com/christoomey/vim-tmux-navigator
#bind-key -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-h) || tmux select-pane -L"
#bind-key -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-j) || tmux select-pane -D"
#bind-key -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-k) || tmux select-pane -U"
#bind-key -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-l) || tmux select-pane -R"
## bind-key -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l"
# pass PgUp & PgDown using xterm-style key sequences (for vim)
set-window-option -g xterm-keys on
# Home and End keys -- usually just leave a ~ in place
## set-option -g terminal-overrides "xterm-color:khome=\033[H:kend=\033[F"
## bind-key Home C-a C-a
## bind-key End C-e
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# MOUSE
# note: these changed significantly in v2.1
# http://stackoverflow.com/questions/35016458/ for great ideas on detecting versions
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.1" | bc)" = 1 ]' \
'set -g mouse off ; bind-key M set -g mouse on \; display-message "Mouse: ON" ; bind-key m set -g mouse off \; display-message "Mouse: OFF"' \
'set -g mode-mouse off' # ; set -g mouse-resize-pane on; set -g mouse-select-pane on; set -g mouse-select-window on'
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# HIDING STUFF
# screen blank/lock
set-option -g lock-after-time 0
set-option -g lock-command '/usr/bin/vlock'
bind-key L lock-server
# clock (screen saver)
bind-key F12 clock-mode
set-window-option -g clock-mode-style 12
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# NICE SHORTCUTS / BINDINGS
# CTRL-A + r reloads the configuration, handy
bind-key r source-file ~/.tmux.conf \; display-message 'sourced ~/.tmux.conf'
# splits
unbind-key % ; bind-key | split-window -h
unbind-key '"' ; bind-key _ split-window -v
# to join two existing windows into 2 panes within a window: join-pane -s XX -t YY
# zoom a pane into its own window (and unzoom)
unbind-key +
unbind-key -
bind-key + new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom
bind-key - last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom
# renumber all windows
unbind-key '#'
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.1" | bc)" = 1 ]' \
'bind-key "#" movew -r \; display-message "renumber windows"' \
'bind-key "#" display-message octothorpe'
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# other global settings
if-shell "[ $OSTYPE == 'linux'* ]" \
'set-window-option -g utf8 on' # mac complains about utf8
set-window-option -g mode-keys vi
set-option -g default-command "exec /usr/local/bin/bash"
set-option -g history-limit 10000
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# MISCELLANEOUS TWEAKS / FIXES
# eliminate ESCAPE delay (see http://www.muddygoat.org/articles/vim-in-tmux)
set-option -sg escape-time 0
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# SSH AGENT RE-CONNECT
# see http://blog.testdouble.com/posts/2016-11-18-reconciling-tmux-and-ssh-agent-forwarding.html
# Remove SSH_AUTH_SOCK to disable tmux automatically resetting the variable
set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"
# Use a symlink to look up SSH authentication
setenv -g SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# COPY/PASTE
# (prefix) [ - start scrollback
# (space) - start highlight in yellow
# v - switch to rectangle copy mode (and back)
# (enter) - copy highlighted bits, stop scrollback
# (prefix) ] - paste the text
# BULK SCROLLBACK SAVE
# (prefix) : capture-pane -S 9000
# (prefix) : save-buffer filename
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~