-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux.conf
212 lines (167 loc) · 7.47 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
# Set prefix to space.
unbind-key C-b
set-option -g prefix C-Space
# Bindings:
# - to see current bindings:
# tmux list-keys
# Open new/split panes with the path of the current pane.
unbind-key c
bind-key c new-window -c '#{pane_current_path}'
unbind-key %
bind-key % split-window -h -c '#{pane_current_path}'
unbind-key '"'
bind-key '"' split-window -v -c '#{pane_current_path}'
# 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 -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
# Colemak bindings
# bind-key -n C-m if-shell "$is_vim" "send-keys C-h" "select-pane -L"
# bind-key -n C-n if-shell "$is_vim" "send-keys C-j" "select-pane -D"
# bind-key -n C-e if-shell "$is_vim" "send-keys C-k" "select-pane -U"
# bind-key -n C-i if-shell "$is_vim" "send-keys C-l" "select-pane -R"
# bind-key -T copy-mode-vi C-m select-pane -L
# bind-key -T copy-mode-vi C-n select-pane -D
# bind-key -T copy-mode-vi C-e select-pane -U
# bind-key -T copy-mode-vi C-i select-pane -R
# Reload tmux config
bind r source-file ~/.tmux.conf
# Move a Tmux Pane to the right
bind H join-pane -h -t !
# Resizing (mouse also works).
unbind-key Left
bind-key -r Left resize-pane -L 5
unbind-key Right
bind-key -r Right resize-pane -R 5
unbind-key Down
bind-key -r Down resize-pane -D 5
unbind-key Up
bind-key -r Up resize-pane -U 5
bind-key S-Left swap-window -t -1\; select-window -t -1
bind-key S-Right swap-window -t +1\; select-window -t +1
# Fast toggle between current and last-used window (normally prefix-l).
bind-key ^space last-window
# `^space ^space` is awfully close to the destructive `^space space`, which
# trashes the layout. Providea quick way to get back to the previous-used
# layout.
#
# Normally used for previous-window, but I never use that, prefering numeric
# access.
bind-key p select-layout -o
# Intuitive window-splitting keys.
bind-key | split-window -h -c '#{pane_current_path}' # normally prefix-%
bind-key \\ split-window -h -c '#{pane_current_path}' # normally prefix-%
bind-key - split-window -v -c '#{pane_current_path}' # normally prefix-"
bind-key v split-window -h -c '#{pane_current_path}' # normally prefix-%
bind-key s split-window -v -c '#{pane_current_path}' # normally prefix-"
# Open the tmux session list
bind-key l choose-session
# Status bar.
set-option -g status-style 'bg=#1f2430,fg=#2f3033'
set-option -g status-left-length 40
set-option -g status-left '#[fg=yellow,bold,italics]#S § ' # SECTION SIGN (UTF-8: c2 a7)
set-option -g status-right "#[fg=yellow]$USER@#h #[fg=magenta]%l:%M %p"
set-option -g status-interval 60 # Default is 15.
# Automatically renumber window numbers on closing a pane (tmux >= 1.7).
set-option -g renumber-windows on
# Highlight active window.
set-option -w -g window-status-style fg=white,bold
set-option -w -g window-status-current-style 'bg=#ffa759,fg=#2f3033,bold'
set-option -w -g xterm-keys on
# Mouse can be used to select panes, select windows (by clicking on the status
# bar), resize panes. For default bindings see `tmux list-keys`.
set-option -g mouse on
# Stay in copy mode on drag end.
# (Would use `bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X
# stop-selection` but it is a bit glitchy.)
unbind-key -T copy-mode-vi MouseDragEnd1Pane
# For those times when C-c and q are not enough.
bind-key -T copy-mode-vi Escape send-keys -X cancel
# Make it so that we can start a copy selection with "v" not just space
bind -T copy-mode-vi v send -X begin-selection
# "y" will copy our selection in copy mode now
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel
# Slightly more useful width in "main-vertical" layout; enough room for 3-digit
# line number gutter in Vim + 80 columns of text + 1 column breathing room
# (default looks to be about 79).
set-option -w -g main-pane-width 85
set-option -g default-terminal "tmux-256color"
# Makes Mintty show lines
set -as terminal-overrides ",*:U8=0"
set-option -ga terminal-overrides ',xterm-256color:Tc'
set -as terminal-overrides ',xterm-256color:sitm=\E[3m'
set-option -as terminal-features ",xterm-256color:RGB"
set-option -g history-limit 4096
# Start window and pane numbering at 1, (0 is too hard to reach).
set-option -g base-index 1
set-option -g pane-base-index 1
# Don't wait for an escape sequence after seeing C-Space.
set-option -s escape-time 0
# Dynamically update iTerm tab and window titles.
set-option -g set-titles on
# Needed as on tmux 1.9 and up (defaults to off).
# Added in tmux commit c7a121cfc0137c907b7bfb.
set-option -g focus-events on
# But don't change tmux's own window titles.
set-option -w -g automatic-rename off
# Don't wrap searches; it's super confusing given tmux's reverse-ordering of
# position info in copy mode.
set-option -w -g wrap-search off
# - #S = session name
# - #T = pane title (~/.zshrc sets this to the last/current command)
set-option -g set-titles-string "#S > #T"
# Show bells in window titles.
set-option -g window-status-bell-style fg=yellow,bold,underscore
# Turn off distracting border highlight.
set-option -ga pane-active-border-style bg=default,fg=default
# Add : to the default list (" -_@") of word separators.
set-option -ga word-separators :
# Make sure we always start at 1, even when invoked from a .tmux wrapper script.
set-environment -g SHLVL 1
# Clipper.
bind-key y run-shell "tmux save-buffer - | nc -U ~/.clipper.sock"
# Search back to last prompt (mnemonic: "[b]ack").
bind-key b copy-mode\; send-keys -X start-of-line\; send-keys -X search-backward "❯"\; send-keys -X next-word
bind-key -T copy-mode-vi / command-prompt -i -p "search down" "send -X search-forward-incremental \"%%%\""
bind-key -T copy-mode-vi ? command-prompt -i -p "search up" "send -X search-backward-incremental \"%%%\""
# Analagous with naked C-l which resets/clears the terminal.
bind C-l send-keys 'C-l'
# Vim style navigation in copy mode
# setw -g mode-keys vi
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-yank'
# Resurrect config
# For vim
set -g @resurrect-strategy-vim 'session'
# For neovim
set -g @resurrect-strategy-nvim 'session'
# Restore pane contents
set -g @resurrect-capture-pane-contents 'on'
# Deletes session "0" after restoring
set -g @resurrect-hook-pre-restore-pane-processes 'tmux switch-client -n && tmux kill-session -t=0'
# Continuum configuration
# Auto start with boot
set -g @continuum-boot 'on'
# Restores sessions when tmux starts
set -g @continuum-restore 'on'
# Add TPM
run -b '~/.tmux/plugins/tpm/tpm'
# Set out default shell
set-option -g default-shell $SHELL