-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
218 lines (171 loc) · 9.57 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
set-option -g mode-keys emacs
set-option -g status-keys emacs
set-option -g set-clipboard on
set-option -g mouse on
# Detach from tmux when closing a session
set-option -g detach-on-destroy on
# Allow 256 colors and true color
set -g default-terminal "screen-256color"
set -g allow-passthrough on
set-option -sg terminal-overrides ",*:RGB"
set-option -as terminal-features ",*:hyperlinks"
# History of tmux commands
set-option -g history-file ~/.tmux_history
set-option -g history-limit 1000
# Scroll up/down by single lines
bind-key -T copy-mode WheelUpPane select-pane \; send-keys -X -N 1 scroll-up
bind-key -T copy-mode WheelDownPane select-pane \; send-keys -X -N 1 scroll-down
bind-key -T copy-mode C-p send-keys -X scroll-up
bind-key -T copy-mode C-n send-keys -X scroll-down
bind-key -T copy-mode C-d send-keys -X halfpage-down
bind-key -T copy-mode C-u send-keys -X halfpage-up
# Select panes with ijkl
bind-key -r -T prefix I select-pane -U
bind-key -r -T prefix J select-pane -L
bind-key -r -T prefix K select-pane -D
bind-key -r -T prefix L select-pane -R
# Copy to clipboard
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-selection -x
bind-key -T copy-mode C-w send-keys -X copy-selection -x
# Search the copy-mode buffer with n/p instead of n/N
# bind-key -T copy-mode p send-keys -X search-reverse
# bind-key -T copy-mode n send-keys -X search-again
# unbind-key -T copy-mode N
# Filed bug https://github.com/tmux/tmux/issues/4309
# bind-key -T copy-mode C-r command-prompt -i -I "#{pane_search_string}" -T search -p "(search up)" { send-keys -X search-backward-incremental "%%" }
# bind-key -T copy-mode C-s command-prompt -i -I "#{pane_search_string}" -T search -p "(search down)" { send-keys -X search-forward-incremental "%%" }
# Split panes in a more intuitive manner
bind-key -T prefix | split-window -h
bind-key -T prefix - split-window -v
# Create new windows and sessions
bind-key -T prefix C-s command-prompt -p "Enter session name:" "new-session -s '%%'"
bind-key -T prefix C-w command-prompt -p "Enter window name:" "new-window -n '%%'"
# Bind prefix + C-R to rename the current window, suggesting the old name
bind-key -T prefix M-w command-prompt -I "#{window_name}" "rename-window '%%'"
bind-key -T prefix M-s command-prompt -I "#{session_name}" "rename-session '%%'"
# Swap panes
bind-key -T prefix \{ swap-pane -U
bind-key -T prefix \} swap-pane -D
# Kill pane without asking confirmation
#bind-key -T prefix & if-shell '[ "#{window_panes}" -eq 1 ] && [ "#{session_windows}" -eq 1 ]' {
# confirm-before -p "This is the last pane in the last window. Kill the server? (y/n)" kill-window } kill-window
bind-key -T prefix & if-shell '[ "#{window_panes}" -eq 1 ] && [ "#{session_windows}" -eq 1 ]' {
set-option -w automatic-rename on
respawn-window -c "$HOME" -k
detach-client
} kill-window
#bind-key -T prefix & confirm-before -p "kill-window #W? (y/n)" kill-window
#bind-key -T prefix x if-shell '[ "#{window_panes}" -eq 1 ] && [ "#{session_windows}" -eq 1 ]' {
# confirm-before -p "This is the last pane in the last window. Kill the server? (y/n)" kill-pane } kill-pane
bind-key -T prefix x if-shell '[ "#{window_panes}" -eq 1 ] && [ "#{session_windows}" -eq 1 ]' {
set-option -w automatic-rename on
respawn-pane -c "$HOME" -k
detach-client
} kill-pane
#bind-key -T prefix x confirm-before -p "kill-pane #P? (y/n)" kill-pane
# Clear screen and history
bind-key -T prefix k send-keys C-l \; run-shell "sleep 0" \; clear-history
# Ctrl-space (comfortable and conflict-Free)
# unbind C-b # Unbind the default prefix
# set-option -g prefix C-Space # Use Ctrl-space as the new prefix
# bind C-Space send-prefix # Send the prefix with Ctrl-space twice
# bind C-x send-prefix # Send the prefix with Ctrl-space twice
# Change prefix only for SSH sessions
if-shell '[ -n "$SSH_CONNECTION" ]' 'unbind C-b ; set -g prefix M-C-b ; bind M-C-b send-prefix'
# Start indexing windows and panes from 1; behavior of sessions cannot be changed
set -g base-index 1
set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on
# Source .tmux.conf as suggested in `man tmux`
bind-key R source-file "~/.tmux.conf" \; display-message "sourced .tmux.conf completed"
# Increase scrollback buffer size
set-option -g history-limit 100000
# pressing CTRL-a sends the configured prefix to the terminal, and thus to the inner tmux sessions; non-prefixed binding with `-n`
# bind -n C-a send-prefix
# pressing CTRL-b-b sends the configured prefix to the terminal, and thus to the inner tmux sessions
# bind b send-prefix
# preserve current directory when creating new window/pane
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}"
# Synchronizes automatically the terminal titles with the window titles
# Disabling it, we avoid dealing with terminal titles in tmux;
# we already control the window titles
set-option -g set-titles off
# set-option -g set-titles-string "#S: #W"
# Land and configure plugins
# === tmux-sensible ===
run-shell "~/.local/share/zinit/plugins/tmux-plugins---tmux-sensible/sensible.tmux"
# === tmux-yank ===
# avoids scrolling back to the end of the buffer after yanking
set-option -g @yank_action 'copy-pipe'
# 'clipboard' / 'primary' / 'secondary'
set-option -g @yank_selection_mouse 'clipboard'
set-option -g @yank_selection 'clipboard'
run-shell "~/.local/share/zinit/plugins/tmux-plugins---tmux-yank/yank.tmux"
# === tmux-fzf-links ===
set-option -g @fzf-links-key C-h
set-option -g @fzf-links-history-lines "0"
if-shell '[ -z "$SSH_CONNECTION" ]' {
set-option -g @fzf-links-editor-open-cmd "open vscode://file'%file':%line"
}{
set-option -g @fzf-links-editor-open-cmd "rmate '%file' --lines %line --port 52150"
}
set-option -g @fzf-links-browser-open-cmd "$HOME/.local/bin/firefox '%url'"
set-option -g @fzf-links-fzf-display-options "-w 100% --maxnum-displayed 15 --multi --track --no-preview"
set-option -g @fzf-links-path-extension "$HOME/.local/share/zinit/polaris/bin"
set-option -g @fzf-links-python "~/.pyenv/versions/py313/bin/python"
set-option -g @fzf-links-python-path ""
set-option -g @fzf-links-user-schemes-path "~/.local/share/zinit/plugins/tmux-plugins---tmux-fzf-links/user_schemes/user_schemes.py"
set-option -g @fzf-links-loglevel-tmux "WARNING"
set-option -g @fzf-links-loglevel-file "DEBUG"
set-option -g @fzf-links-use-colors on
set-option -g @fzf-links-ls-colors-filename "~/.cache/zinit/ls_colors"
set-option -g @fzf-links-hide-fzf-header "on"
# set-option -g @fzf-links-log-filename "~/log.txt"
run-shell "~/.local/share/zinit/plugins/tmux-plugins---tmux-fzf-links/fzf-links.tmux"
# === tmux-menus ===
# set -g @menus_without_prefix yes
set -g @menus_location_x C
set -g @menus_location_y C
set -g @menus_trigger C-\\
run-shell "~/.local/share/zinit/plugins/tmux-plugins---tmux-menus/menus.tmux"
# === tmux-resurrect ===
# Bind resurrect commands
set -g @resurrect-save 'C-M-s'
set -g @resurrect-restore 'C-M-r'
set -g @resurrect-processes 'btop'
run-shell "~/.local/share/zinit/plugins/tmux-plugins---tmux-resurrect/resurrect.tmux"
bind-key 'C-M-r' run-shell "~/.config/dotfiles/bin/tmux_resurrect.zsh ~/.local/share/zinit/plugins/tmux-plugins---tmux-resurrect/resurrect.tmux"
## === Catppuccin theme ===
# Configure the catppuccin plugin
set-option -g @catppuccin_flavor "macchiato"
set-option -g @catppuccin_window_status_style "rounded"
set-option -g @catppuccin_status_background "#282935"
set-option -g @catppuccin_window_text " #{window_name}"
set-option -g @catppuccin_window_current_text " #{window_name}"
set-option -g @catppuccin_host_text " #h"
# Load catppuccin
run-shell "~/.local/share/zinit/plugins/tmux-plugins---tmux-catppuccin/catppuccin.tmux"
# Popup customization after catppuccin
set-option -g popup-border-lines rounded
set-option -g popup-style "bg=#24273a,fg=#cad3f5"
set-option -g popup-border-style "bg=#24273a,fg=#00bbff"
# Make the status line pretty and add some modules
set-option -g status-right-length 100
set-option -g status-left-length 100
set-option -g status-left "#{E:@catppuccin_status_session}"
if-shell '[ -z "$SSH_CONNECTION" ]' {
set-option -g status-right "#{E:@catppuccin_status_host}";
set-option -agF status-right "#{E:@catppuccin_status_date_time}";
# set-option -agF status-right "#{E:@catppuccin_status_battery}";
# set-option -ag status-right "#{E:@catppuccin_status_user}"
# set-option -ag status-right "#{E:@catppuccin_status_application}"
# set-option -agF status-right "#{E:@catppuccin_status_cpu}"
# set-option -ag status-right "#{E:@catppuccin_status_uptime}"
} { set-option -g status-right "" }
# === Extensions for tmux theme ===
# Load two other extensions -- must happen after the theme catppuccin was loaded
run-shell "~/.local/share/zinit/plugins/tmux-plugins---tmux-cpu/cpu.tmux"
# run-shell "~/.local/share/zinit/plugins/tmux-plugins---tmux-battery/battery.tmux"