-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
253 lines (199 loc) · 9.53 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
# vim:set ft=tmux:
# ================= Options
set -g set-clipboard on
setw -g mouse on
set-option -g display-time 500
set-option -g destroy-unattached off
setw -g automatic-rename on
set -g base-index 1 # start windows numbering at 1
setw -g pane-base-index 1 # make pane numbering consistent with windows
set -g renumber-windows on # renumber windows sequentially after closing any of them
#set -g set-titles on # set terminal title
#set -g set-titles-string '#T'
# set -g default-terminal "xterm-256color"
# set-option -sa terminal-overrides ",xterm*:Tc"
# set -g default-terminal "tmux-256color"
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"
set -g status-position top
set -g status-justify centre
# ================== Keymaps
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix M-a
bind M-a send-prefix
bind r source-file ~/.tmux.conf \; display-message "Conf reloaded..."
bind N new-session
# manage tmux sessions
bind M-s run-shell '"$HOME/tmux-sessions.sh"'
bind M-o run-shell '"$HOME/tmux-manager.sh"'
# =============== Pane/Window Control keys ===============
# move b/w panes with C+hjkl
# bind-key C-h select-pane -L
# bind-key C-j select-pane -D
# bind-key C-k select-pane -U
# bind-key C-l select-pane -R
# =============== tmux.nvim stuff start===============
# =============== pane movement ===============
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?\.?(view|n?vim?x?)(-wrapped)?(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L -Z'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D -Z'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U -Z'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R -Z'
bind-key -T copy-mode-vi 'C-h' select-pane -LZ
bind-key -T copy-mode-vi 'C-j' select-pane -DZ
bind-key -T copy-mode-vi 'C-k' select-pane -UZ
bind-key -T copy-mode-vi 'C-l' select-pane -RZ
# bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' }
# bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' }
# bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' }
# bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' }
#
# bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -LZ'
# bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -DZ'
# bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -UZ'
# bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -RZ'
# =============== pane resize ===============
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind -n 'C-Left' if-shell "$is_vim" 'send-keys C-Left' 'resize-pane -L 1'
bind -n 'C-Down' if-shell "$is_vim" 'send-keys C-Down' 'resize-pane -D 1'
bind -n 'C-Up' if-shell "$is_vim" 'send-keys C-Up' 'resize-pane -U 1'
bind -n 'C-Right' if-shell "$is_vim" 'send-keys C-Right' 'resize-pane -R 1'
bind-key -T copy-mode-vi C-Left resize-pane -L 1
bind-key -T copy-mode-vi C-Down resize-pane -D 1
bind-key -T copy-mode-vi C-Up resize-pane -U 1
bind-key -T copy-mode-vi C-Right resize-pane -R 1
# =============== tmux.nvim stuff end ===============
# bind ctrl+left/right to move through windows
bind -n S-right next
bind -n S-left prev
bind l last-window
# Resize panes
# bind-key -r M-h resize-pane -L 2
# bind-key -r M-j resize-pane -D 2
# bind-key -r M-k resize-pane -U 2
# bind-key -r M-l resize-pane -R 2
bind -n M-Enter resize-pane -Z # maximize current pane
# Split panes
bind-key "|" split-window -fh -c "#{pane_current_path}"
bind-key "\\" split-window -h -c "#{pane_current_path}"
bind-key "-" split-window -v -c "#{pane_current_path}"
bind-key "_" split-window -fv -c "#{pane_current_path}"
# Swap panes
bind -n C-S-Up swap-pane -UZ
bind -n C-S-Down swap-pane -DZ
# Swap windows
bind-key -nr C-S-right swap-window -d -t -1
bind-key -nr C-S-left swap-window -d -t +1
# set prefix+a to toggle syncing panes on/off
bind a setw synchronize-panes\; display 'synchronize-panes #{?synchronize-panes,on,off}'
# change pane layouts
# bind 1 select-layout even-horizontal
# bind 2 select-layout even-vertical
# bind 3 select-layout main-horizontal
# bind 4 select-layout main-vertical
# bind 5 select-layout tiled
bind-key c new-window -c "#{pane_current_path}"
# kill window with preifix + k
bind-key k confirm kill-session
bind-key K confirm kill-server
bind-key X confirm kill-window
bind-key x confirm kill-pane
# copy-paste mode
setw -g mode-keys vi
#unbind [
#unbind ]
# Prefix-` to start copy mode
bind ` copy-mode
bind M-c copy-mode
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi V send-keys -X select-line
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
bind-key -T copy-mode-vi Y send-keys -X copy-line-and-cancel
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
# bind -T copy-mode-vi Enter send -X copy-pipe-and-cancel “reattach-to-user-namespace pbcopy”
unbind p
bind p paste-buffer
# Mouse integration ---------------------------------
bind-key m set-option -g mouse \; display-message 'Mouse #{?mouse,on,off}'
# Selection with mouse should copy to clipboard right away, in addition to the default action.
unbind -n -Tcopy-mode-vi MouseDragEnd1Pane
bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel “reattach-to-user-namespace pbcopy”
# unbind -T DoubleClick1Pane
bind -Tcopy-mode-vi DoubleClick1Pane send -X select-word \; send -X copy-pipe-and-cancel “reattach-to-user-namespace pbcopy”
# Middle click to paste from the clipboard
unbind-key MouseDown2Pane
bind-key -n MouseDown2Pane run "tmux set-buffer \"$(xsel -o --clipboard)\"; tmux paste-buffer"
# ZOOM: toggle with right click on pane
unbind-key -n MouseDown3Pane
bind-key -n MouseDown3Pane resize-pane -Z -t=
# Drag to re-order windows
bind-key -n MouseDrag1Status swap-window -t=
# middle click to kill a window
bind-key -n MouseUp2Status kill-window -t=
# Double click on the window list to open a new window
bind-key -n DoubleClick1Status new-window
# --------------------------------------------------------------------------------
# TPM settings
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'fcsonline/tmux-thumbs'
set -g @thumbs-reverse enabled
set -g @plugin 'junegunn/tmux-fzf-url'
# set -g @plugin 'wfxr/tmux-fzf-url'
set -g @fzf-url-bind 'M-x'
set -g @fzf-url-history-limit '2000'
set -g @plugin 'tmux-plugins/tmux-continuum'
# restore session automaticlly
set -g @continuum-save-interval '30'
set -g @continuum-restore 'on'
# set -g @continuum-boot 'on'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-processes 'ssh mysql "~ipython" "~lazygit" "~tail->tail *'
# for vim
set -g @resurrect-strategy-vim 'session'
# for neovim
set -g @resurrect-strategy-nvim 'session'
# load theme
# source "~/tmux-themes/tmux_catpuccin.conf"
# source "~/tmux-themes/tmux_catpuccin.conf"
# catppuccin theme
# add a custom to right status to indicate if panes are pane_synchronized
%hidden MODULE_NAME="pane_sync_status"
# set -ogq "@catppuccin_${MODULE_NAME}_icon" " "
# set -ogqF "@catppuccin_${MODULE_NAME}_color" "##{?pane_synchronized,#{E:@thm_red},#{E:@thm_green}}"
# set -ogq "@catppuccin_${MODULE_NAME}_text" "#{?pane_synchronized,SYNC On,SYNC Off}"
set -ogq "@catppuccin_${MODULE_NAME}_icon" " "
set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{E:@thm_pink}"
set -ogq "@catppuccin_${MODULE_NAME}_text" "#{b:pane_current_path}"
source -F "~/.config/tmux/plugins/catppuccin/tmux/utils/status_module.conf"
set -g @catppuccin_flavor "macchiato"
set -g @catppuccin_window_status_style "rounded"
set -g @catppuccin_window_default_text " #W"
set -g @catppuccin_window_current_text " #W"
set -g @catppuccin_window_status "icon"
set -g @catppuccin_window_current_background "#{@thm_mauve}"
set -g status-left "#{E:@catppuccin_status_session}"
set -g status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"
set -g @catppuccin_date_time_text "%H:%M"
# set -ag status-right "#{E:@catppuccin_status_pane_sync_status}"
set -g @catppuccin_pane_border_style "fg=#{@thm_surface_0}" # Use a value compatible with the standard tmux 'pane-border-style'
set -g @catppuccin_pane_active_border_style "fg=#{@thm_peach}" # Use a value compatible with the standard tmux 'pane-border-active-style'
set -g @catppuccin_menu_selected_style "fg=#{@thm_surface_0},bg=#{@thm_yellow}" # Use a value compatible with the standard tmux `menu-selected-style`
set -g @catppuccin_pane_status_enabled "yes"
set -g @catppuccin_pane_border_status "top" # See `pane-border-status`
set -g @catppuccin_pane_left_separator "█"
set -g @catppuccin_pane_right_separator "█"
set -g @catppuccin_pane_middle_separator "█"
set -g @catppuccin_pane_number_position "left"
set -g @catppuccin_pane_default_fill "number"
set -g @catppuccin_pane_default_text "#{b:pane_current_path}"
set -g @catppuccin_pane_border_style "fg=#{@thm_overlay_0}"
set -g @catppuccin_pane_active_border_style "#{?pane_in_mode,fg=#{@thm_lavender},#{?pane_synchronized,fg=#{@thm_magenta},fg=#{@thm_lavender}}}"
set -g @catppuccin_pane_color "#{@thm_green}"
set -g @catppuccin_pane_background_color "#{@thm_surface_0}"
run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux
run '~/.tmux/plugins/tpm/tpm'