/
.tmux.conf
199 lines (165 loc) · 6.13 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
# https://github.com/orgs/tmux-plugins/repositories?type=all
set -g @plugin 'tmux-plugins/tpm'
# handles `reattach-to-user-namespace`
set -g @plugin 'tmux-plugins/tmux-sensible'
# prefix-F to view keybindings and commands in fzf
set -g @plugin 'sainnhe/tmux-fzf'
# o to open selection in macos
set -g @plugin 'tmux-plugins/tmux-open'
# prefix-u urlview
set -g @plugin 'tmux-plugins/tmux-urlview'
# TODO need status bar for this to be useful
# set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
# prefix-y to copy, prefix-shift-y to copy and paste
set -g @plugin 'tmux-plugins/tmux-yank'
# prefix-/ and prefix-f for pre-built file search
set -g @plugin 'tmux-plugins/tmux-copycat'
# https://github.com/jabirali/tmux-tilish
# TODO is this one better? https://github.com/noscript/tmux-mighty-scroll
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
# prefix-f
set -g @plugin 'abhinav/tmux-fastcopy'
# prefix-tab to extract text from pane
# TODO custom extraction patterns https://github.com/laktak/extrakto#custom-filters
set -g @plugin 'laktak/extrakto'
set -g @plugin 'akohlbecker/aw-watcher-tmux'
# TODO https://github.com/tmux-plugins/tmux-fpp/blob/master/fpp.tmux
# remap prefix to C-h. Some people use C-a, but that conflicts with beginning of line for me. C-b is just annoying.
unbind C-b
set-option -g prefix C-h
bind-key C-h send-prefix
# Enter copy mode with prefix-k, much easier
unbind [
bind-key k copy-mode
# enter copy mode without a prefix!
bind -n C-M-k copy-mode
# other search patterns: C-f for files, C-u for urls
# TODO some broken aspects of this plugin https://github.com/tmux-plugins/tmux-copycat/issues/57#issuecomment-1556043057
# other ideas: https://github.com/tmux-plugins/tmux-copycat/issues/57
# this search below allows for more strict file matching
set -g @copycat_search_C-f '[a-zA-Z0-9_./-]+$'
# push fastcopy into macos clipboard
set-option -g @fastcopy-action pbcopy
# easy reload: prefix+r
# https://til.hashrocket.com/posts/d4d3c1fea6-quickly-edit-and-reload-tmux-configuration
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# https://unix.stackexchange.com/questions/665657/tmux-copy-and-paste-not-working
setw -g mode-keys vi
bind-key -T copy-mode-vi C-a send-keys -X start-of-line
bind-key -T copy-mode-vi C-e send-keys -X end-of-line
# prefix-C to clear the terminal
# https://stackoverflow.com/questions/10543684/how-do-i-clear-the-scrollback-buffer-in-tmux
# TODO can we hook into cmd+k with zsh? https://unix.stackexchange.com/questions/527344/how-to-clear-tmux-and-zsh-history-with-one-keypress
bind-key C send-keys "clear" \; send-keys "Enter" \; clear-history
set -g mouse on
# I'm very nitpicky about the mouse configuration and I've manually configured it below
set -g @yank_with_mouse off
# I don't like the status bar taking up screen real estate
set -g status off
# makes scrolling seem more macos-like
set -g @scroll-speed-num-lines-per-scroll 3
# allows less and other pagers to use the scroll wheel!
set -g @emulate-scroll-for-no-mouse-alternate-buffer on
# easily jump to prompt starts
# https://unix.stackexchange.com/questions/226731/jump-to-last-prompt-in-terminal-or-tmux
bind-key -T copy-mode-vi b {
send-keys -X start-of-line
send-keys -X search-backward "❯"
}
###########################
# less-style page up/down
###########################
# this is how `less` does it, and it feels nice
bind-key -T copy-mode-vi u send-keys -X page-up
bind-key -T copy-mode-vi d send-keys -X page-down
###########################
# option-{Arrow} word navigation
###########################
bind-key -T copy-mode-vi M-f send-keys -X next-word
bind-key -T copy-mode-vi M-b send-keys -X previous-word
###########################
# allow Shift-{Arrows} to be used to start selection AND mutate selection, like macos
###########################
bind-key -T copy-mode-vi 'S-Down' {
if-shell -F '#{selection_present}' {
send-keys -X cursor-down
} {
send-keys -X begin-selection
send-keys -X cursor-down
}
}
bind-key -T copy-mode-vi 'S-Up' {
if-shell -F '#{selection_present}' {
send-keys -X cursor-up
} {
send-keys -X begin-selection
send-keys -X cursor-up
}
}
bind-key -T copy-mode-vi 'S-Right' {
if-shell -F '#{selection_present}' {
send-keys -X cursor-right
} {
send-keys -X begin-selection
send-keys -X cursor-right
}
}
bind-key -T copy-mode-vi 'S-Left' {
if-shell -F '#{selection_present}' {
send-keys -X cursor-left
} {
send-keys -X begin-selection
send-keys -X cursor-left
}
}
bind-key -T copy-mode-vi S-M-Left {
if-shell -F '#{selection_present}' {
send-keys -X previous-word
} {
send-keys -X begin-selection
send-keys -X previous-word
}
}
bind-key -T copy-mode-vi S-M-Right {
if-shell -F '#{selection_present}' {
send-keys -X next-word
} {
send-keys -X begin-selection
send-keys -X next-word
}
}
# make colors inside tmux look the same as outside of tmux
# https://unix.stackexchange.com/questions/348771/why-do-vim-colors-look-different-inside-and-outside-of-tmux
set -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
# expand tmux-fzf plugin to full screen
TMUX_FZF_OPTIONS="-p -w 100% -h 100% -m"
# align word separators with a more standard terminal
# https://github.com/tmux/tmux/issues/3528
set-option -g word-separators " ()[]{}',:;\""
run -b '~/.tmux/plugins/tpm/tpm'
# TODO never got this working, some bug in the macos integration
# set-option -g @plugin 'b0o/tmux-autoreload'
###########################
# macos-style mouse selection
# must run after tpm
###########################
# don't cancel selection when double click ends
# works in copy mode too
bind-key -n DoubleClick1Pane {
select-pane
copy-mode -M
send-keys -X select-word
}
# once we are in copy mode, single click to start new selection
bind -T copy-mode-vi MouseDown1Pane {
select-pane
send-keys -X clear-selection
}
# do not cancel selection when dragging ends
unbind -T copy-mode-vi MouseDragEnd1Pane
unbind -T copy-mode MouseDragEnd1Pane
unbind -T copy-mode-vi DoubleClick1Pane
unbind -T copy-mode DoubleClick1Pane
# set -g aggressive-resize off
# set -g allow-passthrough on