-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_tmux.conf
171 lines (141 loc) · 7.76 KB
/
dot_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
# Ref: https://github.com/Alexis12119/dotfiles/blob/main/tmux/.tmux.conf
##########################################
# GLOBAL CONFIG
set -g mouse on
set -g base-index 1
set -g pane-base-index 1
# set -g set-clipboard on
set -g status-position top
set -g detach-on-destroy off # Don't exit from tmux when closing a session
set -g renumber-windows on # When close a window, renumber windows
set -g default-terminal "${TERM}" # Why screen? https://unix.stackexchange.com/questions/568260/how-is-default-terminal-compared-to-tmux-terminal-overrides
set -ga terminal-overrides ",*-256color:Tc" # RGB is official flag, Tc is tmux extension
# set -g default-terminal "alacritty"
# set-option -sa terminal-overrides ",alacritty*:Tc"
# set -as terminal-overrides ",alacritty*:Tc" # https://www.reddit.com/r/neovim/comments/11usepy/how_to_properly_set_tmux_truecolor_capability/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
# set-option -ga terminal-overrides ',xterm-kitty:cnorm=\E[?12h\E[?25h' # https://github.com/kovidgoyal/kitty/issues/3906
# Set new panes to open in current directory
# Source: https://gist.github.com/william8th/faf23d311fc842be698a1d80737d9631
# bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
set -g history-limit 50000 # Increase history limit
# Neovim suggest (run :healthcheck)
set-option -g focus-events on
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' # Restore beam cursor after exit neovim
set -gq allow-passthrough on # Allow programs in the pane to bypass tmux (needed to render images in nvim, yazi)
set -ga update-environment TERM # From yazi doc to render image
set -ga update-environment TERM_PROGRAM # From yazi doc to render image
##########################################
# KEY BINDINGS
# Change prefix to Ctrl+A
unbind C-b
set -g prefix C-a
bind-key C-a send-prefix
unbind r
bind r source-file ~/.tmux.conf
bind -n M-r respawn-pane -k
bind -r Left resize-pane -L 5
bind -r Down resize-pane -D 5
bind -r Up resize-pane -U 5
bind -r Right resize-pane -R 5
##########################################
# VI MODE
setw -g mode-keys vi
bind-key -T copy-mode-vi 'v' send -X begin-selection # start selecting text with "v"
bind-key -T copy-mode-vi 'y' send -X copy-selection # copy text with "y"
bind-key -T copy-mode-vi WheelUpPane send -N3 -X scroll-up # https://github.com/vercel/hyper/issues/3338
bind-key -T copy-mode-vi WheelDownPane send -N3 -X scroll-down
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
unbind -T copy-mode-vi MouseDragEnd1Pane # don't exit copy mode when dragging with mouse
set -sg escape-time 0 # Remove delay for exiting insert mode with ESC in Neovim
##########################################
# TMUX PLUGINS
# set -g @plugin 'fcsonline/tmux-thumbs' # (prefix space) A lightning fast version of tmux-fingers written in Rust, copy/pasting tmux like vimium/vimperator
# set -g @plugin 'omerxx/tmux-floax' # (prefix P) The missing floating pane for Tmux
# set -g @plugin 'omerxx/tmux-sessionx' # (prefix O) A Tmux session manager, with preview, fuzzy finding, and MORE
set -g @plugin 'Morantron/tmux-fingers' # copy pasting in terminal with vimium/vimperator like hints.
set -g @plugin 'catppuccin/tmux'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'sainnhe/tmux-fzf' # (prefix F) Use fzf to manage your tmux work environment!
set -g @plugin 'tmux-plugins/tmux-continuum' # automatically saves sessions for you every 15 minutes
set -g @plugin 'tmux-plugins/tmux-resurrect' # persist tmux sessions after computer restart
set -g @plugin 'tmux-plugins/tmux-sensible' # Basic tmux settings everyone can agree on
set -g @plugin 'tmux-plugins/tmux-yank' # Tmux plugin for copying to system clipboard. Works on OSX, Linux and Cygwin
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'wfxr/tmux-fzf-url' # 🚀 (prefix u) Quickly open urls on your terminal screen!
##########################################
# CATPPUCCIN THEME CONFIG
# Catppuccin tmux config 3: https://github.com/catppuccin/tmux#config-3
set -g @catppuccin_flavor 'mocha' # latte, frappe, macchiato or mocha
set -g @catppuccin_window_status_style "rounded"
set -g @catppuccin_status_background "default"
run ~/.tmux/plugins/catppuccin/tmux/catppuccin.tmux
set -g status-left ""
set -ogq @catppuccin_pane_status_enabled "yes" # set to "yes" to enable
set -ogq @catppuccin_pane_border_status "yes" # set to "yes" to enable
set -g @catppuccin_window_current_text " #{window_name}"
set -g @catppuccin_window_text " #{window_name}"
set -g status-right "#{E:@catppuccin_status_session}"
set -ag status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_uptime}"
##########################################
# VIM-TMUX-NAVIGATOR CONFIG
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
##########################################
# CONTINUUM CONFIG
# set -g @continuum-boot 'on' # Use 'tmux start-server' on WM/DE instead because it doesn't read fzf config popup
set -g @continuum-restore 'on' # Auto restore
set -g @continuum-save-interval '0' # Disable auto save, let me decide!
set -g @resurrect-save 'M-s'
set -g @resurrect-restore 'M-r'
##########################################
# RESURECT CONFIG
# set -g @resurrect-capture-pane-contents 'on'
# set -g @resurrect-strategy-nvim 'session'
# tmux-resurrect set path: https://github.com/tmux-plugins/tmux-continuum/issues/33#issuecomment-2062756786
set -g @resurrect-dir '~/.tmux_resurrect'
# NOTE: Due to randomly create a new session while restore
# You have to name your sessions
set -g @resurrect-hook-pre-restore-pane-processes 'tmux switch-client -n && tmux kill-session -t=0' # https://github.com/tmux-plugins/tmux-resurrect/issues/101#issuecomment-560026971
##########################################
# SESSIONX
# set -g @sessionx-bind-select-down 'ctrl-n'
# set -g @sessionx-bind-select-down 'tab'
# set -g @sessionx-bind-select-up 'ctrl-p'
# set -g @sessionx-bind-select-up 'shift-tab'
# set -g @sessionx-filter-current 'false'
# set -g @sessionx-layout 'reverse'
# set -g @sessionx-tree-mode 'on'
# set -g @sessionx-window-height '80%'
# set -g @sessionx-window-mode 'on'
# set -g @sessionx-window-width '85%'
# set -g @sessionx-zoxide-mode 'on'
##########################################
# TMUX-THUMBS
# set -g @thumbs-command 'echo -n {} | wl-copy' # For wayland
##########################################
# TMUX-FINGERS
set -g @fingers-key C-f
##########################################
# TMUX-FZF-URL
set -g @fzf-url-extra-filter 'grep -oE "(http|https|ftp)://[a-zA-Z0-9./?=_-]+(:[0-9]+)?"' # It doesn't work because it will match the URL without port before matching this condition
##########################################
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'