-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
93 lines (70 loc) · 3.37 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
# TPM plugins
# (make sure TPM is installed: https://github.com/tmux-plugins/tpm)
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
# increase scrollback buffer size
set -g history-limit 5000
# use xterm-256color
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",*256col*:Tc"
# change prefix to C-a
unbind C-b
set -g prefix C-a
bind-key C-a send-prefix
# fix <esc> delay
set -sg escape-time 20
# source tmuxline conf
if-shell "test -f ~/.tmux-status.conf" "source ~/.tmux-status.conf"
# split using easy to remember keys
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}" -l "30%"
# vim-like window switching (n/N)
bind-key n next-window
bind-key N previous-window
# reorder windows with <C-S-Left> and <C-S-Right>
bind-key -n C-S-Left swap-window -d -t -1
bind-key -n C-S-Right swap-window -d -t +1
# vim-like copy/paste
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
# automatically renumber windows after closing
set -g renumber-windows on
# reload config
bind-key C-r 'source-file ~/.tmux.conf; display-message "Reloaded config"'
# rename window
bind-key r command-prompt -I "#W" "rename-window '%%'"
# remap C-a to C-b so it doesn't conflict with the prefix (shift cursor to start of line)
bind-key -n C-b send-keys C-a
# enable mouse mode
set -g mouse on
# enable pane names
# set -g pane-border-status top
# set -g pane-border-format " #P: #{pane_current_command} "
# 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
# taken from https://github.com/tmux/tmux/issues/140#issuecomment-474341833
# disable "release mouse drag to copy and exit copy-mode", ref: https://github.com/tmux/tmux/issues/140
unbind-key -T copy-mode-vi MouseDragEnd1Pane
# since MouseDragEnd1Pane neither exit copy-mode nor clear selection now,
# let single click do selection clearing for us.
bind-key -T copy-mode-vi MouseDown1Pane select-pane\; send-keys -X clear-selection
# this line changes the default binding of MouseDrag1Pane, the only difference
# is that we use `copy-mode -eM` instead of `copy-mode -M`, so that WheelDownPane
# can trigger copy-mode to exit when copy-mode is entered by MouseDrag1Pane
bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -eM\" \"send-keys -M\"' 'copy-mode -eM'
run '~/.tmux/plugins/tpm/tpm'