-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux.conf
137 lines (120 loc) · 5.63 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
# A tmux configuration, from scratch
# Reference: https://ianthehenry.com/posts/how-to-configure-tmux
# Options
set -g mouse # mouse support
set -g prefix M-w # map a better prefix key. TODO: review
set -g mode-keys vi # <-- vim mode
set -g history-limit 50000
set -g wrap-search off
set -g detach-on-destroy off # QUESTION: what?
set -g bell-action none
set -g pane-active-border-style fg=magenta
set -g status-style bg=#72588c,fg=white
# Remove default keybindings for all modes
unbind -a -T prefix
unbind -a -T root
unbind -a -T copy-mode
unbind -a -T copy-mode-vi
## keybindings
### Meta
bind M-r source-file ~/.tmux.conf
bind Enter command-prompt
bind Space copy-mode
bind M-z suspend-client
# Windows
bind c new-window -a -t '{end}'
bind n command-prompt -p "Session name:" "new-session -s '%1'"
bind Tab select-window -t +
bind Btab select-window -t -
bind M-Tab choose-session
bind C kill-window
bind 1 select-window -t 1
bind 2 select-window -t 2
bind 3 select-window -t 3
bind 4 select-window -t 4
bind 5 select-window -t 5
bind 6 select-window -t 6
bind 7 select-window -t 7
bind 8 select-window -t 8
bind 9 select-window -t 9
# Pane management
bind - split-window -v -c "#{pane_current_path}"
bind | split-window -h -c "#{pane_current_path}"
bind = select-layout even-vertical
bind + select-layout tiled
bind z resize-pane -Z
bind -r R resize-pane -U
bind -r H resize-pane -D
bind -r S resize-pane -L
bind -r T resize-pane -R
# Navigation
bind k select-pane -U
bind j select-pane -D
bind h select-pane -L
bind l select-pane -R
bind M-t select-pane -t :.+
# copy-mode
bind -T copy-mode-vi y send -X copy-pipe-no-clear
bind -T copy-mode-vi r send -X cursor-up
bind -T copy-mode-vi R send -X top-line
bind -T copy-mode-vi h send -X cursor-down
bind -T copy-mode-vi H send -X bottom-line
bind -T copy-mode-vi s send -X cursor-left
bind -T copy-mode-vi S send -X previous-word
bind -T copy-mode-vi t send -X cursor-right
bind -T copy-mode-vi T send -X next-word-end
bind -T copy-mode-vi w command-prompt -1 -p "(jump forward)" { send -X jump-forward "%%%" }
bind -T copy-mode-vi W command-prompt -1 -p "(jump to forward)" { send -X jump-to-forward "%%%" }
bind -T copy-mode-vi d command-prompt -1 -p "(jump backward)" { send -X jump-backward "%%%" }
bind -T copy-mode-vi D command-prompt -1 -p "(jump to backward)" { send -X jump-to-backward "%%%" }
bind -T copy-mode-vi Down send -X scroll-down
bind -T copy-mode-vi S-Down send -X halfpage-down
bind -T copy-mode-vi Up send -X scroll-up
bind -T copy-mode-vi S-Up send -X halfpage-up
bind -T copy-mode-vi g send -X end-of-line
bind -T copy-mode-vi G send -X history-bottom
bind -T copy-mode-vi a send -X start-of-line
bind -T copy-mode-vi A send -X history-top
bind -T copy-mode-vi v send -X rectangle-toggle
bind -T copy-mode-vi V send -X select-line
bind -T copy-mode-vi n send -X search-again
bind -T copy-mode-vi N send -X search-reverse
bind -T copy-mode-vi o send -X other-end
bind -T copy-mode-vi C-c send -X cancel
# Does copy-line respect copy-command? There's no pipe variant.
bind -T copy-mode-vi Enter if -F "#{selection_present}" { send -X copy-pipe-and-cancel } { send -X copy-line }
bind -T copy-mode-vi S-Enter if -F "#{selection_present}" { send -X copy-pipe-and-cancel; paste-buffer -s ' ' } { send -X copy-line; paste-buffer -s ' ' }
bind -T copy-mode-vi Escape if -F "#{selection_present}" { send -X clear-selection } { send -X cancel }
bind -T copy-mode-vi Space if -F "#{selection_present}" { send -X clear-selection } { send -X begin-selection }
bind -T copy-mode-vi / command-prompt -i -p "(search down)" { send -X search-forward-incremental "%%%" }
bind -T copy-mode-vi ? command-prompt -i -p "(search up)" { send -X search-backward-incremental "%%%" }
# Restore unbound mouse commands
bind -T root MouseDown1Pane { select-pane -t =; send -M }
bind -n MouseDown1Status select-window -t =
bind -n MouseDown3Pane if -F -t= "#{mouse_any_flag}" { select-pane -t=; send -M } { select-pane -mt= }
bind -n MouseDrag1Pane if -F -t= "#{mouse_any_flag}" { if -Ft= "#{pane_in_mode}" { copy-mode -M } { send -M } } { copy-mode -M }
bind -n MouseDrag1Border resize-pane -M
bind -n WheelUpPane if -F -t= "#{mouse_any_flag}" { send -M } { if -Ft= "#{pane_in_mode}" { send -M } { copy-mode -et= } }
bind -n WheelUpStatus previous-window
bind -n WheelDownStatus next-window
# Restores unbound copy-mode mouse commands
bind -T copy-mode-vi MouseDown1Pane select-pane
bind -T copy-mode-vi MouseDrag1Pane { select-pane; send -X begin-selection }
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear
bind -T copy-mode-vi WheelUpPane { select-pane; send -X -N 5 scroll-up }
bind -T copy-mode-vi WheelDownPane { select-pane; send -X -N 5 scroll-down }
bind -T copy-mode-vi DoubleClick1Pane { select-pane; send -X select-word }
bind -T copy-mode-vi TripleClick1Pane { select-pane; send -X select-line }
# Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
## Session management -- needs to be loaded last (ref: https://github.com/tmux-plugins/tmux-continuum#known-issues)
set -g @plugin 'tmux-plugins/tmux-resurrect' # restore tmux environment after restart
set -g @plugin 'tmux-plugins/tmux-continuum' # continuous save, automatic restore of tmux env. pairs with `tmux-resurrect`
## Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin '[email protected]:user/plugin'
# set -g @plugin '[email protected]:user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'