-
Notifications
You must be signed in to change notification settings - Fork 33
/
tmux.conf
210 lines (172 loc) · 8.34 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
# TODO: select windows using alt-NR (again)?! - but used in Vim, too.
# Use new tmux-256color terminfo, also provided in ~/.dotfiles/terminfo (via FAQ).
if-shell '[ "$TERM" = "linux" ]' 'set -g default-terminal "tmux"' 'set -g default-terminal "tmux-256color"'
# Use xterm keycodes for Shift-F1 etc (for Vim).
set-window-option -g xterm-keys on
# Set utf8 options only for tmux < 2.2.
if '[ "#{utf8}" ]' 'set -g utf8 on; set -g status-utf8 on; set -g mouse-utf8 on' ''
# Do not use a login shell.
set -g default-command "exec $SHELL"
# Disable terminal capabilities for alternate screen, to make is scrollable in
# the outer terminal emulator (via S-PageUp/S-PageDown).
# Enable S-PageUp/S-PageDown.
# (see byobu bug https://bugs.launchpad.net/byobu/+bug/1258537 and
# http://superuser.com/a/326592/30216)
# NOTE: disabled, because it fails to restore the screen after "attach", when tmux exists
# ("make test" in vim-diminactive).
# set -ga terminal-overrides ",xterm*:smcup@:rmcup@"
# Setup defaults from xterm* also for urxvt (minus Ms for set-selection).
# Asked about this on the mailing list (rejected): https://sourceforge.net/p/tmux/mailman/message/33169870/
set -ga terminal-overrides ",rxvt*:XT:Cs=\\E]12;%p1%s\\007:Cr=\\E]112\\007:Ss=\\E[%p1%d q:Se=\\E[2 q"
# Toggle mouse mode.
bind m run "tmux-toggle-mouse"
# Improved mouse-wheel/page-up handling ("More like old tmux").
# Based on https://bbs.archlinux.org/viewtopic.php?pid=1572580#p1572580.
# NOTE on auto-PPage: `less -X` does not use alternate-screen. Therefore
# this also looks for "less" in pane's ps list
# (based on has_vim from vim-tmux-navigator).
has_less="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -qE '^[^TXZ ]+ +(\S+\/)?less$'"
is_tmux24='[ "#{version}" ]'
if "$is_tmux24" '\
bind -n PPage if-shell -F "#{alternate_on}" "send-keys PPage" "if \"$has_less\" \"send-keys PPage\" \"copy-mode -e; send-keys PPage\"" ;\
bind -Tcopy-mode-vi PPage send -X page-up ;\
bind -Tcopy-mode-vi NPage send -X page-down ;\
bind -Tcopy-mode PPage send -X page-up ;\
bind -Tcopy-mode NPage send -X page-down ;\
bind -Tcopy-mode-vi WheelUpPane send -X halfpage-up ;\
bind -Tcopy-mode-vi WheelDownPane send -X halfpage-down'
# Test for tmux 2.1+ by checking for a new variable.
is_tmux21='[ "#{pid}" ]'
if "! $is_tmux24 && $is_tmux21" '\
bind -n PPage if-shell -F "#{alternate_on}" "send-keys PPage" "if \"$has_less\" \"send-keys PPage\" \"copy-mode -e; send-keys PPage\"" ;\
bind -t vi-copy PPage page-up ;\
bind -t vi-copy NPage page-down ;\
bind -t emacs-copy PPage page-up ;\
bind -t emacs-copy NPage page-down ;\
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= \"#{pane_in_mode}\" \"send-keys -M\" \"select-pane -t=; copy-mode -e; send-keys -M\"" ;\
bind -n WheelDownPane select-pane -t= \; send-keys -M ;\
bind -t vi-copy WheelUpPane halfpage-up ;\
bind -t vi-copy WheelDownPane halfpage-down ;\
bind -t emacs-copy WheelUpPane halfpage-up ;\
bind -t emacs-copy WheelDownPane halfpage-down'
# Enter copy-mode with PageUp explicitly with prefix-PageUp.
# This is useful for when alternate_on is wrong etc.
bind PPage copy-mode -e\; send-keys PPage
# Use C-a as prefix.
# Via http://robots.thoughtbot.com/post/2641409235/a-tmux-crash-course
unbind C-b
set -g prefix C-a
bind a send-prefix
# set -g prefix2 ^
# bind ^ send-prefix -2
# bind C-a send-prefix
# bind C-A send-prefix \; send-prefix
# bind -n C-^ send-keys C-^
# Reload config: unset/reset options that are appended to.
# Unsetting global config vars is fixed in Git for tmux 2.1.
# set -gu update-environment
# set -gu terminal-overrides
_tmux_conf=~/.tmux.conf
bind R source-file $_tmux_conf \; display "Reloaded!"
bind C-a last-window
bind -r Tab select-pane -t :.+
bind -r S-Tab select-pane -t :.-
# via http://jasonwryan.com/blog/2011/06/07/copy-and-paste-in-tmux/
unbind [
bind Escape copy-mode
# unbind p
bind P paste-buffer
bind-key -t vi-copy 'v' begin-selection
# Yank to tmux buffer and X11 selection.
bind-key -t vi-copy 'y' copy-pipe "xsel -i --primary"
# tmux buffer <-> clipboard interaction
bind C-c run "tmux show-buffer | xsel -i --clipboard" \; display 'Copied..'
bind C-v run "tmux set-buffer -- \"$(xsel -o --clipboard)\"; tmux paste-buffer"
set-option -g display-time 4000
set-option -g display-panes-time 4000
# time for repeating of a hotkey bound using the -r flag without having to type the prefix again; default: 500
set-option -g repeat-time 1000
# Resize the window to the size of the smallest session for which it is the
# current window, rather than the smallest session to which it is attached.
set -g aggressive-resize on
set -g history-limit 50000
# Terminal emulator window title
set -g set-titles on
# Use hostname (@#h) in set-titles-string with SSH.
if-shell 'test -n "$SSH_CONNECTION"' 'set -g set-titles-string "[#S:#I.#P @#h:tmux] #T"' 'set -g set-titles-string "[#S:#I.#P:tmux] #T"'
# Do not allow for repeating (-r, default; distracts with shell history).
bind-key Up select-pane -U
# Vim movement keys for moving windows.
bind -r C-H select-window -t :-
bind -r C-L select-window -t :+
# Use 1 as base for windows/panes.
set -g base-index 1
set -g pane-base-index 1
# Resize panes with meta-h/j/k/l (repeats).
bind -r M-h resize-pane -L 6
bind -r M-j resize-pane -D 5
bind -r M-k resize-pane -U 5
bind -r M-l resize-pane -R 5
# Swap panes with Shift-h/j/k/l.
bind H swap-window -t -1
bind L swap-window -t +1
bind J swap-pane -D
bind K swap-pane -U
# vi mode
setw -g mode-keys vi # vim movement keys for switching panes
# Emacs key bindings in tmux command prompt (prefix + :) are better than
# vi keys, even for vim users.
set -g status-keys emacs
# Focus events enabled for terminals that support them.
set -g focus-events on
# # enable maximizing panes
# NOTE: `resize-pane -Z` is available with tmux 1.8 (bound to "z")
# bind S-Up new-window -d -n tmp \; swap-pane -s tmp.0 \; select-window -t tmp
# bind S-Down last-window \; swap-pane -s tmp.0 \; kill-window -t tmp
# Activity Monitoring
# b/B: set/unset bell
bind b setw monitor-activity on \; display "Monitoring activity.."
bind B setw monitor-activity off \; display "Stop monitoring activity.."
set -g visual-activity on
# Removed in 992ef70 (after 1.9a).
# set -g visual-content on
set -g visual-bell off # default
# Sets urgent flag for window manager.
set -g bell-action any # default
# Do not make Esc+key behave like Alt-key.
set -s escape-time 0
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind-key ^ select-pane -l
# restore original C-l
bind C-l send-keys 'C-l'
# Colors, via seebi/tmux-colors-solarized.
# NOTE: done via ~/.dotfiles/usr/bin/sh-setup-x-theme.
# (skips it when started from TTY (TERM=linux))
if '[ "$TERM" != linux ] && [ "$MY_X_THEME_VARIANT" = "light" ]' 'source $HOME/.dotfiles/lib/tmux-colors-solarized/tmuxcolors-light.conf' ''
if '[ "$TERM" != linux ] && [ "$MY_X_THEME_VARIANT" = "dark" ]' 'source $HOME/.dotfiles/lib/tmux-colors-solarized/tmuxcolors-dark.conf' ''
# Window status formats, using #W or #T conditionally (via zsh renaming).
# Uses reverse attribute if the prefix key has been pressed.
set -g status-left '#{?client_prefix,#[underscore],}#S:#{?client_prefix,,#[underscore]}'
set -g window-status-format "#I#F #{=20:?window_name,[#W],#T}"
set -g window-status-current-format "#I#F #{=50:?window_name,[#W],#T}"
set -g status-right ""
set -g -a window-status-activity-style italics
set -g -a window-status-style noitalics
# Automatic rename on by default, indicates that the window name can be set to
# 0/"" via zsh, and gets turned off then (via ~/.oh-my-zsh/lib/termsupport.zsh).
setw -g automatic-rename on
# Make window name "empty" (for the test in window-status-format).
# NOTE: done via zsh once per shell/window.
# rename-window 0
# tmuxstart; like tmuxinator/teamocil, but more inception-like
bind S command-prompt -p "Make/attach session:" "new-window 'tmuxstart \'%%\''"
# Source ~/.tmux.local.conf if it exists.
if '[ -e ~/.tmux.local.conf ]' 'source ~/.tmux.local.conf'