-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_tmux.conf.tmpl
232 lines (188 loc) · 8.85 KB
/
dot_tmux.conf.tmpl
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
# 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 -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/scripts/tmux-manager.sh"'
bind M-w run-shell '"$HOME/scripts/panes.sh"'
# =============== Pane/Window Control keys ===============
# Smart pane switching with awareness of Neovim splits.
# pane-is-vim is set by the smart-split nvim plugin
bind-key -n C-h if -F "#{@pane-is-vim}" 'send-keys C-h' 'select-pane -L'
bind-key -n C-j if -F "#{@pane-is-vim}" 'send-keys C-j' 'select-pane -D'
bind-key -n C-k if -F "#{@pane-is-vim}" 'send-keys C-k' 'select-pane -U'
bind-key -n C-l if -F "#{@pane-is-vim}" 'send-keys C-l' 'select-pane -R'
bind-key -n C-Left if -F "#{@pane-is-vim}" 'send-keys C-Left' 'resize-pane -L 3'
bind-key -n C-Down if -F "#{@pane-is-vim}" 'send-keys C-Down' 'resize-pane -D 3'
bind-key -n C-Up if -F "#{@pane-is-vim}" 'send-keys C-Up' 'resize-pane -U 3'
bind-key -n C-Right if -F "#{@pane-is-vim}" 'send-keys C-Right' 'resize-pane -R 3'
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 -F \"#{@pane-is-vim}\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if -F \"#{@pane-is-vim}\" 'send-keys C-\\\\' 'select-pane -l'"
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
# bind ctrl+left/right to move through windows
bind -n S-right next
bind -n S-left prev
bind l last-window
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 ]
# Alt-a + Alt-C for 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'
# tmux thumbs====================
set -g @plugin 'fcsonline/tmux-thumbs'
set -g @thumbs-unique enabled
set -g @thumbs-regexp-1 '([\w-]+(?:\.[\w-]*)*)' # match filenames with extensions
# set -g @thumbs-regexp-2 '(\w+-\w+\.\w+\.\w+\.\w+)' # match filenames with extensions
set -g @thumbs-reverse enabled
# tmux thumbs====================
# tmux fzf-url ====================
set -g @plugin 'junegunn/tmux-fzf-url'
set -g @fzf-url-bind 'M-x'
set -g @fzf-url-history-limit '2000'
# tmux fzf-url ====================
# tmux continum & resurrect ====================
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'
# tmux continum & resurrect ====================
# theme ====================
set -g @plugin 'catppuccin/tmux#v1.0.3'
{{- if (and (eq .chezmoi.os "linux") (eq "mariner" .chezmoi.osRelease.id) (contains "rdev" (env "RDEV_ID")) (eq "coder" .chezmoi.username)) }}
# use a different flavor on rdev
set -g @catppuccin_flavor 'frappe'
set -g @catppuccin_window_current_background "#{@thm_mauve}"
{{- else }}
set -g @catppuccin_flavor "macchiato"
{{- end }}
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-length 100
set -g status-left "#{E:@catppuccin_status_host}"
set -g @catppuccin_host_text "#h"
set -g status-right-length 200
# Define a tmux command to get the truncated path
set -ogq @truncated_path "#(bash $HOME/scripts/truncate_path.sh #{pane_current_path})"
set -g status-right "#{E:@catppuccin_status_directory}"
set -g @catppuccin_directory_text "#{E:@truncated_path}"
set -ag status-right "#{E:@catppuccin_status_session}"
# set -ag status-right "#{E:@catppuccin_status_date_time}"
# set -g @catppuccin_date_time_text "%H:%M"
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}"
# theme ====================
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
run '~/.tmux/plugins/tpm/tpm'