-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
267 lines (222 loc) · 10.3 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
258
259
260
261
262
263
264
265
266
267
bind ? split-window -v -p 60 'echo -n "tmux help\n\
Sessions <prefix>-( and ) - move between sessions\n\
<prefix>-L - ‘last’ (previously used) session\n\
<prefix>-s - choose a session from a list\n\
<prefix>-$ - rename session\n\
\n\
Windows <prefix>-w - select window from list\n\
<prefix>-l - select last window\n\
<prefix>-1,9,n,p - navigate between windows\n\
<prefix>-, - rename window\n\
<prefix>-c - create window\n\
<prefix>-& - kill window\n\
<prefix>-left,right - move window left right\n\
\n\
Panes <prefix>-h,j,k,l,o - move between panes\n\
<prefix>-e - select-layout even-horizontal\n\
<prefix>-z - maximise pane\n\
<prefix>-q - show pane numbers\n\
<prefix>-; - goto last pane\n\
<prefix>-H,J,K,L - resize panes\n\
<prefix>-{,} - move pane\n\
<prefix>-<space> - switch layout (select-layout even-horizontal, even-vertical, main-horizontal, main-vertical, tiled)\n\
<prefix>-c-o - rotate panes\n\
<prefix>-v,b - split vertically horizontally\n\
<prefix>-x - kill pane\n\
\n\
Press Enter to continue\
"; read'
# ---------------------------- General
# history
set -g history-limit 100000
# color
# set -g default-terminal "screen-256color"
# set -g default-terminal "tmux-256color"
# set -ag terminal-overrides ",xterm-256color:RGB"
# https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6
set -g default-terminal "xterm-256color"
set -ag terminal-overrides ",xterm-256color:RGB"
# C-b is not acceptable -- Vim uses it, use 'C-\'
unbind-key C-b
set -g prefix 'C-\'
bind-key 'C-\' send-prefix
# Can you have both?
#bind-key 'C-\' last-window
# Start numbering at 1 - nice cause it lines up with number keys
set -g base-index 1
# Allows for faster key repetition
set -s escape-time 0
# Necessary for pbcopy with OSC52
# https://medium.com/free-code-camp/tmux-in-practice-integration-with-system-clipboard-bcd72c62ff7b
set -g set-clipboard on
# Rather than constraining window size to the maximum size of any client
# connected to the *session*, constrain window size to the maximum size of any
# client connected to *that window*. Much more reasonable.
setw -g aggressive-resize on
# Activity monitoring
setw -g monitor-activity on
set -g visual-activity on
# Highlight active window
#set-window-option -g window-status-current-bg red
# auto renumber windows when deleted
set-option -g renumber-windows on
# auto window rename
#set-window-option -g automatic-rename
# rm mouse mode fail
#set -g mode-mouse off
set-option -g mouse on
# --------------------------- Keybindings
# Vi copy mode
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi 'v' send -X begin-selection # Begin selection in copy mode.
bind-key -T copy-mode-vi 'C-v' send -X rectangle-toggle # Begin selection in copy mode.
bind-key -T copy-mode-vi 'y' send -X copy-selection # Yank selection in copy mode.
#bind p paste-buffer
bind t run-shell -b "tmux list-windows -a -F \"##{window_id}: [##{session_name}] ##{window_name} ##{window_activity}\" | column -t | sort -k 4 -r | fzf-tmux | cut -d \":\" -f 1 | xargs tmux switch-client -t"
# hjkl pane traversal
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# alt-hjkl resize
bind -r ˙ resize-pane -L 3
bind -r ˚ resize-pane -U 1
bind -r ∆ resize-pane -D 1
bind -r ¬ resize-pane -R 3
# layout
bind e select-layout even-horizontal
# reload config
bind r source-file ~/.tmux.conf \; display-message "Config reloaded!"
# Move left and right - tabs
# https://superuser.com/questions/343572/how-do-i-reorder-tmux-windows
bind-key -n C-Left swap-window -t -1\; select-window -t -1
bind-key -n C-Right swap-window -t +1\; select-window -t +1
# clear the current pane
unbind C-l
#bind -n C-l send-keys C-l \; clear-history
bind C-l send-keys C-l \; clear-history
# screen splits
unbind '"' # h
unbind % # v
bind v split-window -h -c "#{pane_current_path}" # tmux is reversed
bind b split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# synchronise panes - not sure this currently works, meant to copy this pane to all other panes in window?
bind y set-window-option synchronize-panes
# pane management
#bind t break-pane # or <prefix> ! - moves pane to new window # Doesn't work
# https://unix.stackexchange.com/questions/14300/moving-tmux-pane-to-window
#alt-j
bind-key ∆ choose-window 'join-pane -h -t "%%"'
#bind ∆ command-prompt -p "send pane to:" "join-pane -h -t '%%'"
# https://unix.stackexchange.com/questions/145857/how-do-you-hide-a-tmux-pane
bind-key ! break-pane -d -n _hidden_pane
bind-key $ join-pane -s $.0
# convenience for switching windows
bind C-n next-window
bind C-p previous-window
# ---------------------------- Plugins
#### Plugins
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
# last saved environment is automatically restored when tmux is started.
set -g @continuum-restore 'on'
set -g @continuum-save-interval '10'
# for vim
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-capture-pane-contents 'on'
# Resurrect shortcuts:
# prefix s - save
# prefix r - restore
# dtmux - delete tmux session (bash alias)
set -g @plugin 'seebi/tmux-colors-solarized'
set -g @colors-solarized 'light'
set -g @plugin 'sainnhe/tmux-fzf'
TMUX_FZF_LAUNCH_KEY="C-f"
bind-key "C-s" run-shell -b "~/.tmux/plugins/tmux-fzf/scripts/window.sh switch"
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-fpp'
set -g @fpp-mode 'paste'
# <prefix> f to open a window with path (brew install fpp)
set -g @plugin 'tmux-plugins/tmux-urlview'
# <prefix> u to open a url with path (brew install urlview extract_url)
set -g @plugin 'tmux-plugins/tmux-open'
# <prefix> o - open highlighted app
# <prefix> C-o - open in editor
# <prefix> S - google search
set -g @open-S 'https://www.google.com/search?q='
# net speed (doesn't have macos support)
#set -g @plugin 'tmux-plugins/tmux-net-speed'
# Battery indicator
set -g @plugin 'tmux-plugins/tmux-battery'
# CPU tmux
#set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @cpu_low_bg_color "#[fg=colour7,bg=colour14]"
#set -g @cpu_medium_bg_color "#[fg=colour8,bg=#ffff00]"
set -g @cpu_low_fg_color "#[fg=white]"
set -g @cpu_medium_fg_color "#[fg=colour8]"
set -g @cpu_high_fg_color "#[fg=white]"
set -g @cpu_high_thresh "50"
#set -g @cpu_high_bg_color "#[bg=#ff0000]"
set -g @plugin 'nhdaly/tmux-scroll-copy-mode'
# Enter copy mode when scrolling up
set -g @plugin 'tmux-plugins/tmux-yank'
# Copy to clipboard, not just local buffer
set -g status-interval 10
set -g status-right '#{prefix_highlight}#{battery_color_bg} #[fg=white]#{battery_percentage} #[bg=default]#{cpu_bg_color}#[fg=white]#{cpu_fg_color} CPU: #{cpu_percentage} #[fg=colour7,bg=colour11] %a %Y-%m-%d %H:%M:%S '
# From vim-airline you get this:
#[
# 'set -g status-justify "left"',
# 'set -g status "on"',
# 'set -g status-left-style "none"',
# 'set -g message-command-style "fg=colour7,bg=colour14"',
# 'set -g status-right-style "none"',
# 'set -g pane-active-border-style "fg=colour11"',
# 'set -g status-style "none,bg=colour7"',
# 'set -g message-style "fg=colour7,bg=colour14"',
# 'set -g pane-border-style "fg=colour14"',
# 'set -g status-right-length "100"',
# 'set -g status-left-length "100"',
# 'setw -g window-status-activity-style "none,fg=colour11,bg=colour7"',
# 'setw -g window-status-separator ""',
# 'setw -g window-status-style "none,fg=colour14,bg=colour7"',
# 'set -g status-left "#[fg=colour7,bg=colour11,bold] #S:#I #[fg=colour11,bg=colour7,nobold,nounderscore,noitalics]"',
# 'set -g status-right "#[fg=colour14,bg=colour7,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour14] %a | %Y-%m-%d | %l:%M%p #[fg=colour11,bg=colour14,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour11] #(whoami) "',
# 'setw -g window-status-format "#[fg=colour7,bg=colour7,nobold,nounderscore,noitalics]#[default] #I | #W #[fg=colour7,bg=colour7,nobold,nounderscore,noitalics]"',
# 'setw -g window-status-current-format "#[fg=colour7,bg=colour14,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour14] #I | #W #[fg=colour14,bg=colour7,nobold,nounderscore,noitalics]"',
#];
set -g @plugin 'tmux-plugins/tmux-sessionist'
# prefix + g - prompts for session name and switches to it. Performs 'kind-of' name completion.
# Faster than the built-in prefix + s prompt for long session lists.
# prefix + C (shift + c) - prompt for creating a new session by name.
# prefix + X (shift + x) - kill current session without detaching tmux.
# prefix + S (shift + s) - switches to the last session.
# The same as built-in prefix + L that everyone seems to override with some other binding.
# prefix + @ - promote current pane into a new session.
# Analogous to how prefix + ! breaks current pane to a new window.
# prefix + t<secondary-key> - join currently marked pane (prefix + m) to current session/window, and switch to it
# secondary-keys
# h, -, ": join horizontally
# v, |, %: join vertically
# f, @: join full screen
# initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# ------------------------ Layout
# https://stackoverflow.com/questions/25532773/change-background-color-of-active-or-inactive-pane-in-tmux/33553372#33553372
# http://www.deanbodenham.com/learn/tmux-pane-colours.html
# Colours go after so that they're not overridden
set -g pane-border-style bg=colour7,fg=black
set -g pane-active-border-style bg=colour15
set -g window-style 'fg=default,bg=colour7'
set -g window-active-style 'fg=default,bg=colour15'
# ---------------------------- Status bar config
set -g status-justify left # center align window list
set -g status-left-length 20
set -g status-right-length 140
set -g status-left '>'
set -g status-style fg=default,bg=colour7
set -g status-left "#[fg=colour7,bg=colour11,bold] #S:#I #[fg=colour11,bg=colour7,nobold,nounderscore,noitalics]"
setw -g window-status-format "#[fg=colour7,bg=colour7,nobold,nounderscore,noitalics]#[default] #I | #W #[fg=colour7,bg=colour7,nobold,nounderscore,noitalics]"
setw -g window-status-current-format "#[fg=colour7,bg=colour14,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour14] #I | #W #[fg=colour14,bg=colour7,nobold,nounderscore,noitalics]"