-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.tmux.conf
More file actions
208 lines (182 loc) · 9.63 KB
/
.tmux.conf
File metadata and controls
208 lines (182 loc) · 9.63 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
# Core editor options
# remap prefix from 'C-b' to 'C-s'
unbind C-b
set-option -g prefix C-s
bind-key C-s send-prefix
# Necessary for Powerline
# tells tmux it has 256-color capabilities
set -g default-terminal "screen-256color"
# reload config file
bind r source-file ~/.tmux.conf
# Mouse mode
set -g mouse on
setw -g mode-keys vi
# History limit
set -g history-limit 8192
# Plugins
# Tmux plugin management
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-yank' # Not working rn: See https://github.com/tmux-plugins/tmux-yank
set -g @yank_action 'copy-pipe-no-clear'
# Look into this at some point https://github.com/tmux-plugins/tmux-sessionist
#set -h @plugin 'tmux-plugins/tmux-sessionist'
# file navigation: https://github.com/tmux-plugins/tmux-sidebar/blob/master/docs/options.md
set -g @treemux-tree-nvim-init-file '~/.tmux/plugins/treemux/configs/treemux_init.lua'
set -g @plugin 'kiyoon/treemux'
#set -g @sidebar-tree-command 'tree -C'
set -g @sidebar-tree-width '60'
set -g @sidebar-tree-command 'fzf'
# pretty theme uwu
set -g @nord_tmux_no_patched_font "0" # until I get powerline fonts working ig
set -g @plugin 'arcticicestudio/nord-tmux'
# plugin to restore tmux windows on reboot
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @resurrect-save 'S'
set -g @resurrect-restore 'R'
set -g @resurrect-strategy-vim 'session' # make it restore vim correctly
set -g @resurrect-capture-pane-contents 'on'
# These bindings are for X Windows only. If you're using a different
# window system you have to replace the `xsel` commands with something
# else. See https://github.com/tmux/tmux/wiki/Clipboard#available-tools
bind -T copy-mode DoubleClick1Pane select-pane \; send -X select-word \; send -X copy-pipe-no-clear "xsel -i"
bind -T copy-mode-vi DoubleClick1Pane select-pane \; send -X select-word \; send -X copy-pipe-no-clear "xsel -i"
bind -n DoubleClick1Pane select-pane \; copy-mode -M \; send -X select-word \; send -X copy-pipe-no-clear "xsel -i"
bind -T copy-mode TripleClick1Pane select-pane \; send -X select-line \; send -X copy-pipe-no-clear "xsel -i"
bind -T copy-mode-vi TripleClick1Pane select-pane \; send -X select-line \; send -X copy-pipe-no-clear "xsel -i"
bind -n TripleClick1Pane select-pane \; copy-mode -M \; send -X select-line \; send -X copy-pipe-no-clear "xsel -i"
bind -n MouseDown2Pane run "tmux set-buffer -b primary_selection \"$(xsel -o)\"; tmux paste-buffer -b primary_selection; tmux delete-buffer -b primary_selection"
# Pane/window management & navigation
# Start pane/window indices at 1
set -g base-index 1
setw -g pane-base-index 1
# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
unbind Space
# Order using names instead of indexes, which I cannot seem to change
bind s choose-tree -sZ -O name
bind w run-shell "tmux choose-tree -Z -w -f '##{==:#{session_name},##{session_name}}'"
# 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'"
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
# Clear screen using prefix+C-l
bind C-l send-keys 'C-l'
# switch panes using prefix-hjkl
bind h select-pane -L
bind l select-pane -R
bind j select-pane -D
bind k select-pane -U
# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# ezpz move windows up/down in the list
bind-key S-Left swap-window -t -1\; select-window -t -1
bind-key S-Right swap-window -t +1\; select-window -t +1
# Search for windows
bind-key f command-prompt "choose-tree -Z -w -s -f '#{m/i:*%%*,#{session_name}}'"
bind-key F run-shell 'tmux command-prompt "choose-tree -Z -f \"##{&&:##{m/i:*%%*,##{window_name}},##{==:#{session_name},##{session_name}}}\""'
# TODO custom switcher script: https://www.reddit.com/r/tmux/comments/111jmf8/how_to_reorder_sessions/
# Window titles
# enable wm window titles
set -g set-titles on
# stop tmux from renaming my shit
set -g automatic-rename off
set -g allow-rename off
# quick set/clear of window title suffixes
# TODO make this ignore ☛ windows
bind N command-prompt {run-shell 'base=$(tmux display-message -p ${session_name} | gsed -E "s/\[([^-]*\S)(\s*-.*)?\].*/\\1/"); if [[ -n "%1" ]]; then tmux rename-session -t "#{session_name}" "${base} - %1"; else tmux rename-session -t "#{session_name}" "${base}"; fi'}
# Statusbar
# Make room for my session names
set-option -ag status-left-length 30
# TODO https://arcolinux.com/everything-you-need-to-know-about-tmux-status-bar/
# Misc
# stop esc from taking forever
set -s escape-time 1
set -g status-interval 0
# Make mouse-mode copies goto my clipboard
# doesn't work with my work x-forwarding setup >:(
bind -T copy-mode C-c send -X copy-pipe-no-clear "xsel -i --clipboard"
bind -T copy-mode-vi C-c send -X copy-pipe-no-clear "xsel -i --clipboard"
# Useful popups
# Ty to this thread for how to toggle
# https://www.reddit.com/r/tmux/comments/olgte7/floating_popups_in_tmux/
#bind-key -n M-` if-shell -F '#{==:#{session_name},☛scratch}' {
# detach-client
#} {
# display-popup -w 80% -h 80% -E "tmux new-session -A -s ☛scratch -c ~"
#}
#bind-key -n C-M-b if-shell -F '#{==:#{session_name},☛btop}' {
# detach-client
#} {
# display-popup -w 50% -h 75% -E "tmux attach-session -t ☛btop"
#}
new-session -A -s "☛ system-utils" -n "dotfiles" -c "~/dotfiles"
new-window -S -n "packages"
new-window -S -n "btop" btop
choose-tree -sZ -O name
# Superseded by cooler menu option
bind-key -n M-` if-shell -F '#{==:#{=1:session_name},☛}' {
detach-client
} {
# TODO make the options create the window/command if it doesn't already exist
display-menu -x C -y C -T "System Utilities" \
"☛ scratch " ` 'display-popup -w 80% -h 80% -E "tmux new-session -A -s \"☛ scratch\" -c ~"' \
"☛ dotfiles " 1 'display-popup -w 80% -h 80% -E "tmux new-session -- tmux switch-client -t \"☛ system-utils:dotfiles\""' \
"☛ packages " 2 'display-popup -w 80% -h 80% -E "tmux new-session -- tmux switch-client -t \"☛ system-utils:packages\""' \
"☛ btop " 3 'display-popup -w 80% -h 80% -E "tmux new-session -- tmux switch-client -t \"☛ system-utils:btop\""'
}
bind-key ` if-shell -F '#{==:#{=1:session_name},☛}' {
detach-client
} {
# TODO make the options create the window/command if it doesn't already exist
display-menu -x C -y C -T "System Utilities" \
"☛ scratch " ` 'display-popup -w 80% -h 80% -E "tmux new-session -A -s \"☛ scratch\" -c ~"' \
"☛ dotfiles " 1 'display-popup -w 80% -h 80% -E "tmux new-session -- tmux switch-client -t \"☛ system-utils:dotfiles\""' \
"☛ packages " 2 'display-popup -w 80% -h 80% -E "tmux new-session -- tmux switch-client -t \"☛ system-utils:packages\""' \
"☛ btop " 3 'display-popup -w 80% -h 80% -E "tmux new-session -- tmux switch-client -t \"☛ system-utils:btop\""'
}
# Do the same with middle mouse key
# https://www.seanh.cc/2020/12/28/binding-keys-in-tmux/
bind-key -n MouseDown2Pane if-shell -F '#{==:#{=1:session_name},☛}' {
display-menu -x M -y M -T "System Utilities" \
"☚ exit " Esc 'detach-client' \
"☛ scratch " ` 'switch-client -t ☛ scratch' \
"☛ dotfiles " 1 'switch-client -t ☛ system-utils:dotfiles' \
"☛ packages " 2 'switch-client -t ☛ system-utils:packages' \
"☛ btop " 3 'switch-client -t ☛ system-utils:btop'
} {
# TODO make the options create the window/command if it doesn't already exist
display-menu -x M -y M -T "System Utilities" \
"☛ scratch " ` 'display-popup -w 80% -h 80% -E "tmux new-session -A -s \"☛ scratch\" -c ~"' \
"☛ dotfiles " 1 'display-popup -w 80% -h 80% -E "tmux new-session -- tmux switch-client -t \"☛ system-utils:dotfiles\""' \
"☛ packages " 2 'display-popup -w 80% -h 80% -E "tmux new-session -- tmux switch-client -t \"☛ system-utils:packages\""' \
"☛ btop " 3 'display-popup -w 80% -h 80% -E "tmux new-session -- tmux switch-client -t \"☛ system-utils:btop\""'
}
bind-key -n MouseDown2Border send-keys -M MouseDown2Pane
bind-key -n MouseDown2Status send-keys -M MouseDown2Pane
bind-key -n MouseDown2StatusLeft send-keys -M MouseDown2Pane
bind-key -n MouseDown2StatusRight send-keys -M MouseDown2Pane
bind-key -n MouseDown2StatusDefault send-keys -M MouseDown2Pane
# Init TPM MUST REMAIN LAST
run '~/.tmux/plugins/tpm/tpm'