-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
257 lines (199 loc) · 8.8 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# Hierarchy:
# Server
# └─Session
# └─Window
# └─Pane
# Options:
# - Session options (set-option [-g])
# - Window options (set-window-option [-g])
# -------------------------------------------------------------------
# Server options
# -------------------------------------------------------------------
# See if this fixes slow ESC issues.
# http://unix.stackexchange.com/questions/23138/esc-key-causes-a-small-delay-in-terminal-due-to-its-alt-behavior
set -s escape-time 0
# -------------------------------------------------------------------
# Session options
# -------------------------------------------------------------------
# Change bind key to ctrl-a
unbind-key C-b
set-option -g prefix C-a
# Start window and pane indices at 1.
set-option -g base-index 1
set-option -g pane-base-index 1
# Renumber windows when a window is closed
set-option -g renumber-windows on
# History
set-option -g history-limit 102400
# Repeat time limit (ms)
set-option -g repeat-time 500
# Use tmux-256color
set-option -s default-terminal 'tmux-256color'
# Default mouse-mode
set-option -g mouse on
# Unbork my iTerm ctrl+1 etc mappings in tmux 2.1
# https://github.com/tmux/tmux/issues/159
set-option -g assume-paste-time 0
# Enable True Color
# Ref: https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6
set-option -s terminal-overrides '*:RGB'
# Set default size for larger width
set-option -g default-size 190x53
# Update environment variables
set-option -ga update-environment TERM
set-option -ga update-environment TERM_PROGRAM
# -------------------------------------------------------------------
# Window options
# -------------------------------------------------------------------
# Use vim keybindings in copy mode
set-option -wg mode-keys vi
# -------------------------------------------------------------------
# Key bindings
# -------------------------------------------------------------------
# Repeat prefix to send prefix
bind-key C-a send-prefix
# Capture pane and save to ~/tmux.history (in the home directory of user that execute tmux)
bind-key P command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S - ; save-buffer %1 ; delete-buffer'
# pane movement
bind-key J command-prompt -p "join pane from:" "join-pane -s ':%%'"
bind-key S command-prompt -p "send pane to:" "join-pane -t ':%%'"
# Moving windows
bind-key -r > swap-window -d -t :+
bind-key -r < swap-window -d -t :-
# Highlight the active window in the status bar.
set-option -gw window-status-current-style 'fg=black bg=yellow'
# pass "Ptmux;" escape sequences through to the terminal
set-option -gw allow-passthrough on
# Don't prompt to kill panes/windows.
bind-key x kill-pane
bind-key & kill-window
# Pane-movement.
bind-key h select-pane -L
bind-key l select-pane -R
bind-key j select-pane -D
bind-key k select-pane -U
bind-key tab select-pane -t :.+
bind-key btab select-pane -t :.-
# Select last window
# tmux can only use single quote, need to escape awk variable
bind-key g run-shell 'last_window_index=$(tmux list-windows | tail -1 | awk -F ":" "{ print \$1 }"); tmux select-window -t :=${last_window_index}'
# Last window
bind-key "'" last-window
# Window movement
bind-key '"' command-prompt -p index "select-window -t ':%%'"
# More intuitive split-window mappings.
bind-key | split-window -h -c "#{pane_current_path}"
bind-key - split-window -v -c "#{pane_current_path}"
# Synchronize panes
bind-key * set-window-option synchronize-pane
# Maximize pane, e.g. for copying.
bind-key z resize-pane -Z
# Switch pane and zoom
# https://twitter.com/tskogberg/status/792025881573199872
bind-key C-z select-pane -t :.+ \; resize-pane -Z
# Reload tmux conf.
unbind-key r
bind-key r source-file ~/.tmux.conf\; display "Reloaded conf."
# Update $DISPLAY
bind-key u run-shell 'TMUX_DISPLAY="$(tmux_get_env TMUX_DISPLAY)"; [ -n "$TMUX_DISPLAY" ] && tmux set-environment DISPLAY "$TMUX_DISPLAY"'\; display "Update \$DISPLAY to #(tmux_get_env DISPLAY)"
# List panes information
bind-key C-q list-panes -a -F "#{pane_pid} #{session_name}:#{window_index}.#{pane_index}"
# copy-mode
# http://robots.thoughtbot.com/tmux-copy-paste-on-os-x-a-better-future
# Setup 'v' to begin selection as in Vim
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi C-v send -X rectangle-toggle
bind-key -T copy-mode-vi y send -X copy-pipe "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode-vi Enter send -X copy-selection-and-cancel
# Capture pane and open in Vim
bind-key C-c run-shell 'FILE=/tmp/tmux-capture-$(date +%Y%m%d%H%M%S).txt; tmux capture-pane -J -S -102400 -p > $FILE; tmux new-window "$EDITOR $FILE"'
# Clear scrollback buffer
bind-key C-l send-keys C-l \; clear-history
# Switch to last background process
# require fgl to work
bind-key b run-shell 'tmux send-keys C-z; sleep 0.1; tmux send-keys fgl Enter'
# Switch to background processes using fzf
# require ffg to work
bind-key B run-shell 'tmux send-keys C-z; sleep 0.1; tmux send-keys ffg Enter'
# Workaround for issue that 'C-g C-h' cannot be send to terminal inside tmux if $TERM is 'xterm'
# BSpace == 'C-h' if $TERM is 'xterm'
bind-key BSpace send-keys C-g C-h
# Show key binding
bind-key ? list-keys
# Show clock
bind-key T clock-mode
# Quickly switch window & session
bind-key -n M-\" last-window
bind-key -n M-L switch-client -l
# -------------------------------------------------------------------
# Decoration (256-color)
# -------------------------------------------------------------------
# Status bar styling and content.
set-option -g status-interval 60
# Use tmux-gruvbox-dark colorscheme instead
# Custom colorscheme {{{
# Status line {{{
# set-option -g status-bg black
# set-option -g status-fg white
# set-option -g status-left '#S '
# Show keyboard layout in prompt, assuming some script writes it to that path;
# it's "/User/…" instead of "~" so VMs can read from their symlinked OS X host home directory.
# set-option -g status-right '#(cat /Users/$USER/.keyboard_layout 2> /dev/null) | #22T | #{t:window_activity}'
# set-option -g status-right-length 60
# }}}
# window titles {{{
# set-window-option -g window-status-current-format ' #[fg=white]** #[fg=white,bold][#{window_index}] #[fg=green]#{pane_current_command} #[fg=cyan]#(pwd="#{pane_current_path}"; echo ${pwd####*/}) #[fg=white]**'
# set-window-option -g window-status-format '#[fg=colour244,bold][#{window_index}] #[fg=colour244]#{pane_current_command} #[fg=colour244]#(pwd="#{pane_current_path}"; echo ${pwd####*/})'
# }}}
# Statusbar theme for X sessions or tty.
# if-shell '[ -n "$DISPLAY" ] && [ -f ~/.tmux/seoul256-powerline.tmux ]' 'source ~/.tmux/seoul256-powerline.tmux'
# }}}
# -------------------------------------------------------------------
# fzf integration
# -------------------------------------------------------------------
# Use fzf to select pane
# require tmux 3.2 for display-popup support
bind-key 0 run-shell "tmux display-popup -E -w90% -h80% 'bash -c \"source ~/.bash_aliases; ftpane\"'"
# -------------------------------------------------------------------
# Plugins
# -------------------------------------------------------------------
# List of plugins
set-option -g @plugin 'tmux-plugins/tpm'
set-option -g @plugin 'tmux-plugins/tmux-sensible'
set-option -g @plugin 'tmux-plugins/tmux-resurrect'
set-option -g @plugin 'tmux-plugins/tmux-yank'
set-option -g @plugin 'tmux-plugins/tmux-open'
set-option -g @plugin 'tmux-plugins/tmux-fpp'
# set-option -g @plugin 'tmux-plugins/tmux-copycat' # disable to avoid 'n' being slowed
set-option -g @plugin 'laktak/extrakto'
set-option -g @plugin 'egel/tmux-gruvbox'
set-option -g @plugin 'sainnhe/tmux-fzf'
# set-option -g @plugin 'graelo/tmux-copyrat'
set-option -g @plugin 'Morantron/tmux-fingers'
set-option -g @plugin 'fcsonline/tmux-thumbs'
# private plugins:
set-option -g @plugin '[email protected]:mars90226/tmux-auto.git'
set-option -g @plugin '[email protected]:mars90226/tmux-project-word.git'
# Other examples:
# set-option -g @plugin 'github_username/plugin_name'
# set-option -g @plugin '[email protected]/user/plugin'
# set-option -g @plugin '[email protected]/user/plugin'
# tmux-fpp options
set-option -g @fpp-key 't'
# tmux-open options
set-option -g @open-S 'https://www.duckduckgo.com/?q='
# extrakto options
set-option -g @extrakto_key '`'
set-option -g @extrakto_split_size 15
# tmux-fzf options
TMUX_FZF_LAUNCH_KEY="C-f"
# tmux-fingers options
set-option -g @fingers-key 'F'
# tmux-thumbs options
set-option -g @thumbs-key 'f'
# tmux-auto, not on github
# if-shell '[ -f ~/.tmux/plugins/tmux-auto/tmux-auto.tmux ]' 'source ~/.tmux/plugins/tmux-auto/tmux-auto.tmux'
# require tmux 3.2 for display-popup support
bind-key e run-shell "tmux display-popup -E -w90% -h80% \"PANE='#{pane_id}' ~/.tmux/plugins/tmux-auto/list_scripts_and_exec.sh\""
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run-shell '~/.tmux/plugins/tpm/tpm'