-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtmux.conf
More file actions
330 lines (247 loc) · 12 KB
/
tmux.conf
File metadata and controls
330 lines (247 loc) · 12 KB
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# ████████╗███╗ ███╗██╗ ██╗██╗ ██╗
# ╚══██╔══╝████╗ ████║██║ ██║╚██╗██╔╝
# ██║ ██╔████╔██║██║ ██║ ╚███╔╝
# ██║ ██║╚██╔╝██║██║ ██║ ██╔██╗
# ██║ ██║ ╚═╝ ██║╚██████╔╝██╔╝ ██╗
# ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
# Terminal multiplexer
# https://github.com/tmux/tmux
# FYI: check for true color support using:
# - `scripts/truecolor-test.sh` (in dotfiles)
# should draw a seamless gradient
# - `tmux info | grep -e RGB -e Tc`
# should return:
# 197: RGB: (flag) true
# 223: Tc: (flag) true
# set default shell to zsh
# https://github.com/tmux/tmux/issues/4166
set -g default-shell /bin/zsh
set -g default-command "$SHELL"
set -g extended-keys off
set-option -gas terminal-overrides "*:Tc" # true color support
set-option -gas terminal-overrides "*:RGB" # true color support
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm' # undercurl support
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' # underscore colours - needs tmux-3.0
# https://github.com/neovim/neovim/wiki/FAQ#cursor-shape-doesnt-change-in-tmux
set -g -a terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
# additional support for alacritty
set -as terminal-features ",alacritty*:RGB"
# allow zenmode in Neovim + wezterm
# see https://github.com/folke/zen-mode.nvim#wezterm
set-option -g allow-passthrough on
# act like vim
setw -g mode-keys vi
# enable focus events
set -g focus-events on
# default pane switching for when things break
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# we lost the default binding of C-l for clearing screen
# this line of code fixes it by allowing us to use prefix + C-l
bind C-l send-keys 'C-l'
# setup leader key
unbind C-b
set -g prefix C-z
# shortcuts for iterating on tmux config
bind-key r source-file ~/.config/tmux/tmux.conf \; display-message 'tmux.conf reloaded'
bind-key M split -h 'vim ~/.config/tmux/tmux.conf'
# ==============================================================
# Appearance
# ==============================================================
# TokyoNight colors for Tmux
set -g mode-style "fg=#7aa2f7,bg=#3b4261"
set -g message-style "fg=#7aa2f7,bg=default"
set -g message-command-style "fg=#7aa2f7,bg=default"
set -g pane-border-style "fg=#3b4261"
set -g pane-active-border-style "fg=#3b4261"
# top border style
set -g pane-border-format ""
setw -g pane-border-status top
# formatting and configuration for status text
set -g status-style "fg=#7aa2f7,bg=default"
setw -g window-status-activity-style "underscore,fg=#a9b1d6,bg=default"
setw -g window-status-separator ""
setw -g window-status-style "NONE,fg=#a9b1d6,bg=default"
set -g status-right "#{prefix_highlight} #{battery_icon_charge} #{battery_percentage} #[fg=#3b4261,bg=default,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261] %I:%M %p #[fg=#7aa2f7,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#1D202F,bg=#7aa2f7,bold] #{online_status} #{tmux_mode_indicator}"
set -g status-left "#[fg=#1D202F,bg=#7aa2f7,bold] #S #[bg=default,fg=#7aa2f7,bold]#[bg=default]"
set -g status-left-length 150
set -g status-right-length 150
set -g status-interval 5
set -g status-justify left
set -g status-position top
# window title
# tmux tab (window name) styling
set -g window-status-format "#[fg=#2a2e40]#[bg=#2a2e40,fg=#565d83] #I #W #[fg=#2a2e40,bg=default]"
set -g window-status-current-format "#[fg=#ffffff]#[fg=#1d202f,bg=#ffffff] #I #W #[fg=#ffffff,bg=default]"
# prevent auto window renaming once I renamed it
set -g allow-rename off
# ==============================================================
# Pane Stuff
# ==============================================================
# splitting and creating new windows
bind-key - split-window -v -c '#{pane_current_path}'
bind-key \\ split-window -h -c '#{pane_current_path}'
bind-key c new-window -c '#{pane_current_path}'
bind b break-pane -d
# Use up and down arrows for temporary "maximize"
unbind Up; bind Up resize-pane -Z
unbind Down; bind Down resize-pane -Z
# Resize tmux panes and Vim windows with ease (alt+hjkl)
# Manual resize bindings (replacing better-vim-tmux-resizer functionality)
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n M-h if-shell "$is_vim" "send-keys M-h" "resize-pane -L 10"
bind-key -n M-j if-shell "$is_vim" "send-keys M-j" "resize-pane -D 5"
bind-key -n M-k if-shell "$is_vim" "send-keys M-k" "resize-pane -U 5"
bind-key -n M-l if-shell "$is_vim" "send-keys M-l" "resize-pane -R 10"
bind-key -T copy-mode-vi M-h resize-pane -L 10
bind-key -T copy-mode-vi M-j resize-pane -D 5
bind-key -T copy-mode-vi M-k resize-pane -U 5
bind-key -T copy-mode-vi M-l resize-pane -R 10
# ==============================================================
# Window (Tab) Stuff
# ==============================================================
# double press C-z to toggle tabs (windows)
bind C-z last-window
bind Tab last-window
# Reorder windows
bind Left swap-window -t -\; previous-window # move window one position to the left
bind Right swap-window -t +\; next-window # move window one position to the right
# ==============================================================
bind C-s choose-tree
# eliminate delays when switching modes in vim
set -sg escape-time 10
# start window numbers at 1 to match keyboard order with tmux window order
set -g base-index 1
set-window-option -g pane-base-index 1
# renumber windows sequentially after closing any of them
set -g renumber-windows on
# increase scrollback lines
set -g history-limit 100000
# prefix -> back-one-character
bind-key C-b send-prefix
# prefix-2 -> forward-incremental-history-search
bind-key C-s send-prefix -2
# =======================================
# Sessions
# ======================================
# break into new session
bind-key C-b send-keys 'tat && exit' 'C-m'
# don't detach from tmux when closing a session (just open a different session)
set -g detach-on-destroy off
# session manager fuzzy finder using sesh + tv
bind-key "T" run-shell "tmux-popup-sesh"
# tmux windows/panes picker (tmux-ff replacement)
bind-key "W" run-shell "tmux-popup-windows"
bind-key "K" run-shell "tmux-popup-panes"
# toggles to last session
bind -N "last-session (via sesh) " L run-shell "mise x -- sesh last"
# create new session with gum input
bind-key "N" run-shell "tmux-popup-new-session"
# fork github repo and create session
bind-key "v" run-shell "tmux-popup-fork-repo"
# open a dev dir in a tmux session or switch to one if exists
bind-key "O" run-shell "tmux-popup-open-dev-dir"
# create new linear issue
bind-key "i" run-shell "tmux-popup-linear"
# insert file path at cursor (for AI agents like OpenCode/Claude Code)
bind-key "A" run-shell "tmux-popup-insert-file-path"
# ghostty command palette (cmd-p)
bind-key "P" display-popup -E -w 60% -h 60% "mise x -- tv tmux-commands --layout portrait --hide-status-bar"
# =======================================
# Copy paste stuff
# =================================================
# Allows scrolling and selecting in copy-mode
set -g mouse on
bind -n WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
bind -n WheelDownPane select-pane -t= \; send-keys -M
bind-key -T edit-mode-vi Up send-keys -X history-up
bind-key -T edit-mode-vi Down send-keys -X history-down
unbind-key -T copy-mode-vi Space
unbind-key -T copy-mode-vi Enter
unbind-key -T copy-mode-vi C-v
unbind-key -T copy-mode-vi [
unbind-key -T copy-mode-vi ]
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi [ send-keys -X begin-selection
bind-key -T copy-mode-vi ] send-keys -X copy-selection
# =================================================
# Plugin Setup
# =================================================
# use kagi for searching selected term (<prefix>shift-s)
set -g @open-S 'https://www.kagi.com/search?q='
#==================================================
# Plugins
# =================================================
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# show if connected to internet
set -g @online_icon " "
set -g @offline_icon " "
set -g @plugin 'aserowy/tmux.nvim'
# for online status
set -g @online_icon "#[fg=#9dd78e,bold] online"
set -g @offline_icon "#[fg=#e5706b,bold] offline!"
set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @plugin 'tmux-plugins/tmux-sessionist'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
# Plugin that displays prompt indicating currently active Tmux mode.
set -g @plugin 'MunifTanjim/tmux-mode-indicator'
###################################
### tmux-open-nvim ####
###################################
set -g @ton-prioritize-window true
# open files/urls selected in copy mode
set -g @plugin 'trevarj/tmux-open-nvim'
###################################
###################################
### tmux-fingers ####
###################################
set -g @fingers-key F
set -g @fingers-skip-wizard true
# support for tmux-open-nvim
# Overrides matching file paths with :[line]:[col] at the end
set -g @fingers-pattern-0 '(([.\w\-~\$@]+)?(/[.\w\-@]+)+/?)(:\d*){,2}'
# adds files with no directory (e.g. Taskfile.dist.yml) as long as they have
# an extension (also picks up version numbers and domain names :shrug:)
set -g @fingers-pattern-1 '(\/?[\w\-])+(\.\w+)+(:\d+){,2}'
# Launches helper script on shift+[key] in fingers mode
# set -g @fingers-shift-action "xargs -I {} tmux run-shell 'cd #{pane_current_path}; ton {} 2>&1 /tmp/ton.log'"
set -g @fingers-shift-action "xargs -I{} tmux run-shell 'cd #{pane_current_path}; ton {} >> /tmp/ton.log'"
# /support for tmux-open-nvim
# copy pasting in terminal with vimium/vimperator like hints
set -g @plugin 'Morantron/tmux-fingers'
###################################
# use fzf to copy text from tmux into current command (prefix+TAB)
set -g @plugin 'laktak/extrakto'
# open urls on the tmux screen, and allow selecting one via fzf
set -g @fzf-url-bind 'x'
set -g @fzf-url-fzf-options '-p70% -m -0 --no-preview'
set -g @plugin 'joshmedeski/tmux-fzf-url'
# show battery status
set -g @batt_icon_status_charged ''
set -g @batt_icon_status_charging ''
set -g @batt_icon_status_discharging ' '
set -g @batt_icon_charge_tier8 ''
set -g @batt_icon_charge_tier7 ''
set -g @batt_icon_charge_tier6 ''
set -g @batt_icon_charge_tier5 ''
set -g @batt_icon_charge_tier4 ''
set -g @batt_icon_charge_tier3 ''
set -g @batt_icon_charge_tier2 ''
set -g @batt_icon_charge_tier1 ''
set -g @plugin 'tmux-plugins/tmux-battery'
# =================================================
# Local config
if-shell "[ -f ~/.tmux.conf.local ]" 'source ~/.tmux.conf.local'
# install tpm if not already installed
if "test ! -d ~/.local/share/tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.local/share/tmux/plugins/tpm'"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.local/share/tmux/plugins/tpm/tpm'