-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
227 lines (170 loc) · 8.25 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
## -- set-options ------------------------------------------------------------
# colors!
set -g default-terminal "screen-256color"
# set -g default-terminal "tmux-256color"
set -g default-command "${SHELL}"
set -g default-shell "${SHELL}"
# faster command sequences
set -s escape-time 10
set -s focus-events on
# expect UTF-8 (tmux < 2.2)
set -q -g status-utf8 on
# start windows numbering at 1
set -g base-index 1
# renumber windows when a window is closed
set -g renumber-windows on
# set terminal title
set -g set-titles on
# slightly longer pane indicators display time
set -g display-panes-time 800
# slightly longer status messages display time
set -g display-time 1000
# activity
set -g monitor-activity on
set -g visual-activity off
set -s escape-time 0
# increase history size
set -g history-limit 10000
# increase repeat timeout
set -sg repeat-time 300
# start with mouse mode enabled
set -g mouse on
# force Vi mode
# really you should export VISUAL or EDITOR environment variable, see manual
set -g status-keys vi
set -g mode-keys vi
# move status line to top
set -g status-position top
set -g set-titles-string '#H Session: #S CW: #I #W'
set -g status-interva 1
set -g status-style bg="colour238",fg="colour255"
set -g status-left-length 50
set -g status-left "#[fg=colour255,bg=colour241]%Y/%m/%d %H:%M:%S|#H|Session:#S|#{prefix_highlight} "
set -g status-right "#[fg=colour255,bg=colour241] #{online_status} #{cpu_icon} #{cpu_percentage} #{battery_icon} #{battery_percentage}"
set -ga terminal-overrides ",alacritty:Tc"
# set -ga terminal-overrides ",xterm-termite:Tc"
## -- set-window-options -----------------------------------------------------
setw -g window-status-format "#I:#W "
setw -g window-status-current-format "#[fg=colour255,bg=colour171]#I: #W "
setw -g aggressive-resize on
# make pane numbering consistent with windows
setw -g pane-base-index 1
# rename window to reflect current program
setw -g automatic-rename on
setw -g xterm-keys on
# expect UTF-8 (tmux < 2.2)
setw -q -g utf8 on
## -- key binding ------------------------------------------------------------
### -- unbind default key bind -----------------------------------------------
# prefix
unbind C-a
unbind C-b
# window navigation
unbind n
unbind p
# Explicit `Enter` key fires copying the selection
unbind -T copy-mode-vi MouseDragEnd1Pane
### -- bind-key --------------------------------------------------------------
# prefix
set -g prefix C-s
bind C-s send-prefix
# buffers
bind b list-buffers # list paste buffers
bind p paste-buffer # paste from the top paste buffer
bind P choose-buffer # choose which buffer to paste from
# edit configuration
bind e new-window -n '~/.tmux.conf' "sh -c '\${EDITOR:-nvim} ~/.tmux.conf && tmux source ~/.tmux.conf && tmux display \"~/.tmux.conf sourced\"'"
# reload configuration
bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced'
#### -- navigation -----------------------------------------------------------
# create session
bind C-c new-session
# find session
bind C-f command-prompt -p find-session 'switch-client -t %%'
# create new session, window, and split-window
bind n switch-client -Tnew
bind -Tnew c switch-client -Tcurrent
bind -Tnew s command-prompt -I "new-session -s "
bind -Tnew w new-window
bind -Tnew - split-window -v
bind -Tnew | split-window -h
bind -Tcurrent s new-session -c "#{pane_current_path}" # create new session with current directory
bind -Tcurrent w new-window -c "#{pane_current_path}" # create new window with current directory
bind -Tcurrent - split-window -v -c "#{pane_current_path}" # split current window vertically init with current directory
bind -Tcurrent | split-window -h -c "#{pane_current_path}" # split current window horizontally init with current directory
# pane navigation
bind -r h select-pane -L # move left
bind -r j select-pane -D # move down
bind -r k select-pane -U # move up
bind -r l select-pane -R # move right
bind > swap-pane -D # swap current pane with the next one
bind < swap-pane -U # swap current pane with the previous one
# pane resizing
bind -r H resize-pane -L 10
bind -r J resize-pane -D 10
bind -r K resize-pane -U 10
bind -r L resize-pane -R 10
# Window navigation
bind -r C-h previous-window # select previous window
bind -r C-l next-window # select next window
bind Tab last-window # move to last active window
bind S-Left swap-window -t -1
bind S-Right swap-window -t +1
# # Switch clients
# bind H switch-client -p
# bind L switch-client -n
# Explicit `Enter` key fires copying the selection
# bind -T copy-mode-vi y send-keys -X copy-pipe 'tmux copy-buffer | tmux save-buffer - | yank > #{pane_tty} | tmux cancel'
# bind -T copy-mode y send-keys -X copy-pipe-and-cancel 'tmux copy-buffer | tmux save-buffer - | yank > #{pane_tty} | tmux cancel'
bind -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux copy-buffer | tmux save-buffer - | yank > #{pane_tty} | tmux cancel'
# copy with OSC 52(this needs yank script)
if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1 && command -v yank > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | yank > #{pane_tty}"'
# transfer copied text to attached terminal with yank
bind -T copy-mode-vi y send-keys -X copy-pipe 'yank > #{pane_tty}'
# transfer most-recently copied text to attached terminal with yank
bind -n M-y run-shell 'tmux save-buffer - | yank > #{pane_tty}'
# transfer previously copied text (chosen from a menu) to attached terminal
bind -n M-Y choose-buffer 'run-shell "tmux save-buffer -b \"%%%\" - | yank > #{pane_tty}"'
# vi-choice is gone in tmux >= 2.4
run -b 'tmux bind -t vi-choice h tree-collapse 2> /dev/null || true'
run -b 'tmux bind -t vi-choice l tree-expand 2> /dev/null || true'
run -b 'tmux bind -t vi-choice K start-of-list 2> /dev/null || true'
run -b 'tmux bind -t vi-choice J end-of-list 2> /dev/null || true'
run -b 'tmux bind -t vi-choice H tree-collapse-all 2> /dev/null || true'
run -b 'tmux bind -t vi-choice L tree-expand-all 2> /dev/null || true'
run -b 'tmux bind -t vi-choice Escape cancel 2> /dev/null || true'
# vi-edit is gone in tmux >= 2.4
run -b 'tmux bind -ct vi-edit H start-of-line 2> /dev/null || true'
run -b 'tmux bind -ct vi-edit L end-of-line 2> /dev/null || true'
run -b 'tmux bind -ct vi-edit q cancel 2> /dev/null || true'
run -b 'tmux bind -ct vi-edit Escape cancel 2> /dev/null || true'
### -- copy mode --
bind Enter copy-mode # enter copy mode
run -b 'tmux bind -t vi-copy v begin-selection 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi v send -X begin-selection 2> /dev/null || true'
run -b 'tmux bind -t vi-copy C-v rectangle-toggle 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi C-v send -X rectangle-toggle 2> /dev/null || true'
run -b 'tmux bind -t vi-copy y copy-selection 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi y send -X copy-selection-and-cancel 2> /dev/null || true'
run -b 'tmux bind -t vi-copy Escape cancel 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi Escape send -X cancel 2> /dev/null || true'
run -b 'tmux bind -t vi-copy H start-of-line 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi H send -X start-of-line 2> /dev/null || true'
run -b 'tmux bind -t vi-copy L end-of-line 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi L send -X end-of-line 2> /dev/null || true'
# copy to Mac OSX clipboard
if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | reattach-to-user-namespace pbcopy"'
# copy to X11 clipboard
if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xsel -i -b"'
if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1"'
# copy to Windows clipboard
if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | clip.exe"'
if -b '[ -c /dev/clipboard ]' 'bind y run -b "tmux save-buffer - > /dev/clipboard"'
# -- plugins -----------------------------------------------------------------
set -g @plugin 'tmux-plugins/tpm'
#set -g @plugin 'tmux-plugins/tmux-battery'
#set -g @plugin 'tmux-plugins/tmux-online-status'
#set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @prefix_highlight_show_copy_mode 'on'
run -b '~/.tmux/plugins/tpm/tpm'