-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
457 lines (412 loc) · 25.5 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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
# CTRL-Q is much natural than CTRL-B, and doesn't clash with screen's CTRL-A.
# (CTRL-Q = XOFF anyway, which you most likely don't use in the 21st century)
set -g prefix c-q
# Design. Use only plain unicode, still look somewhat special. No powerline special font needed
#sepa='' # Design #0
#sepa='▌' # Design #1
#sepa='▌▌' # Design #2
#sepa='▚' # Design #3
#sepa='▄' # Design #4
#sepa='▏▎▍▌▋▊▉' # Design #5
sepa='▎▌▊' # Design #6
# Status command on the right, between the clock and the screen size.
#mystat="%Y-%m-%d %a" # Date with DOW, OS independent
mystat="#(ipconfig getifaddr en0 || echo No WiFi)" # WiFi IP on OS X
# Theme originally from https://github.com/jimeh/tmux-themepack/blob/master/powerline/block/magenta.tmuxtheme
# and slightly modified (see below). You can find other color schemes there too!
# I switched color90 => color125
set -g status-style fg=colour240,bg=colour233
set -g status-left-style bg=colour233,fg=colour243
set -g status-right-style bg=colour233,fg=colour243
set -g status-right-length 150
set -g window-status-format " #I:#W#F "
set -g window-status-current-format " #I:#W#F "
set -g window-status-current-style bg=colour125,fg=colour232
set -g window-status-activity-style bg=colour233,fg=colour141
set -g window-status-separator ""
set -g status-justify centre
set -g pane-border-style bg=default,fg=colour238
set -g pane-active-border-style bg=default,fg=colour125
set -g display-panes-colour colour233
set -g display-panes-active-colour colour245
set -g clock-mode-colour colour125
set -g clock-mode-style 24
set -g message-style bg=colour125,fg=black
set -g message-command-style bg=colour233,fg=black
set -g mode-style bg=colour125,fg=colour231
# Modifications compared to the original theme
set -g status-left-length 100
set -g status-left "#[fg=colour232,bg=colour125,bold] #S:#I.#P#{?client_last_session, S, -}#{?mouse,, [NOMOUSE]}#{?session_many_attached, [MANY],""}#{?synchronize-panes, [BROADCASTING],""}#{?window_zoomed_flag, [ZOOM],""}#{?pane_pipe, [PIPE],""} #[fg=colour240,bg=colour125,nobold]$sepa#[fg=colour233,bg=colour240] #{?client_prefix,Q,-}#{?#{==:#{client_key_table},inject},R,-} #{?alternate_on,A,-} #{?monitor-activity,a,-}#{?monitor-silence,s,-} #[fg=colour235,bg=colour240]$sepa#[fg=colour240,bg=colour235] #{pane_pid} #[fg=colour233,bg=colour235,nobold]$sepa"
set -g status-right "#[fg=colour235,bg=colour233]$sepa#[fg=colour240,bg=colour235] %H:%M %Z #[fg=colour240,bg=colour235]$sepa#[fg=colour233,bg=colour240] $mystat #[fg=colour245,bg=colour240]$sepa#[fg=colour232,bg=colour245,bold] #{pane_width}x#{pane_height} "
# Force the status line to ON
set -g status on
# Always use ~ as the dir for new panes, not wherever tmux was started from
#attach-session -t . -c ~
# Allow to send CTRL-Q
bind q send-prefix
# CTRL-Q CTRL-Q goes back to last window, like in screen
bind c-q last-window
#set -g base-index 1
# To make screen easier to use if accidentally hit CTRL-Q instead of CTRL-A or CTRL-W
bind c-a send-keys c-a
bind a send-keys c-a
bind w send-keys c-w
# Toggle broadcasting input to all panes.
bind b set synchronize-panes
# Toggle tmux "mouse" functionality
# XXX c-m is not really usable: it's ENTER
#bind "c-m" set mouse
# Copy mode
bind Escape copy-mode
# Paste immediately
bind c-p paste-buffer
# Select what buffer to paste
bind p choose-buffer -Z
bind P choose-buffer
# Keys INSIDE copy-mode
bind -T copy-mode-vi Escape send -X cancel
bind -T copy-mode-vi Space send -X clear-selection
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi V send -X select-line
bind -T copy-mode-vi C-v send -X rectangle-toggle
bind -T copy-mode-vi Enter send -X copy-selection-and-cancel
bind -T copy-mode-vi y send -X copy-selection-and-cancel
bind -T copy-mode-vi Y send -X append-selection-and-cancel
bind -T copy-mode-vi c-y send -X copy-pipe-and-cancel 'cat >>~/Desktop/tmux-copy.#S.#I.#P.#W.txt'
# Copy to numbered buffers
bind -T copy-mode-vi "\"" switch-client -T copy-mode-vi-registers
bind -T copy-mode-vi-registers "1" send -X copy-selection-and-cancel \; set-buffer -n 1
bind -T copy-mode-vi-registers "2" send -X copy-selection-and-cancel \; set-buffer -n 2
bind -T copy-mode-vi-registers "3" send -X copy-selection-and-cancel \; set-buffer -n 3
bind -T copy-mode-vi-registers "4" send -X copy-selection-and-cancel \; set-buffer -n 4
bind -T copy-mode-vi-registers "5" send -X copy-selection-and-cancel \; set-buffer -n 5
bind -T copy-mode-vi-registers "6" send -X copy-selection-and-cancel \; set-buffer -n 6
bind -T copy-mode-vi-registers "7" send -X copy-selection-and-cancel \; set-buffer -n 7
bind -T copy-mode-vi-registers "8" send -X copy-selection-and-cancel \; set-buffer -n 8
bind -T copy-mode-vi-registers "9" send -X copy-selection-and-cancel \; set-buffer -n 9
bind -T copy-mode-vi-registers "?" list-keys -T copy-mode-vi-registers
# Set word separators for word selection
set -g word-separators " `'\"{}()[],;<>"
# Write to system clipboard, but don't read it
set -s set-clipboard external
# Pane management
bind Enter select-pane -m
bind S join-pane
bind V join-pane -h
bind o break-pane
bind O break-pane -d
# Various comfort settings stolen from all over the net
set -g default-terminal screen-256color
set -g status-keys vi
set -g renumber-windows on
set -g history-limit 100000
set -g mode-keys vi
set -g mouse on
# Automatically set window title
set -g automatic-rename on
set -g set-titles on
# No delay for escape key press
set -sg escape-time 0
# Leave messages on longer (or until keypress)
set -g display-time 1500
# Switch to a remaining session if one session is exited
set -g detach-on-destroy off
# Split vertically
bind v split-window -h
# Split horizontally
bind s split-window -v
# Window chooser
bind "\"" choose-window -Z
bind "\'" choose-session -Z
# New session
bind C command-prompt "new-session -s '%%'"
# Rename window
bind A command-prompt -I "#W" "rename-window '%%'"
# Move pane to window
bind m choose-window -Z "move-pane -h -t '%%'"
# Move window to session and switch to there
bind M choose-session -Z "move-window -t \"%1\"; switch-client -t \"%1\""
# Move window left and right
bind , swap-window -d -t -1
bind . swap-window -d -t +1
# Switch windows with C-Tab and C-S-Tab.
# Should be:
#bind-key -n C-Tab next-window
#bind-key -n C-S-Tab previous-window
# Instead, what works (plus, need to add this to iTerm):
set -s user-keys[0] "\e[1;5I"
set -s user-keys[1] "\e[1;6I"
bind-key -n User0 next-window
bind-key -n User1 previous-window
# Pane layouts
bind > next-layout
bind < previous-layout
# Spread out panes equally
bind = select-layout -E
# Move panes around
# XXX Same as default
#bind { swap-pane -U
#bind } swap-pane -D
# Pane resize options
bind J resize-pane -D 5
bind K resize-pane -U 5
bind H resize-pane -L 5
bind L resize-pane -R 5
# Vim style pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind c-h select-pane -L
bind c-j select-pane -D
bind c-k select-pane -U
bind c-l select-pane -R
bind [ select-pane -t :.-
bind ] select-pane -t :.+
bind Tab select-pane -t :.+
bind i display-panes
# Use Alt-arrow keys without prefix key to switch panes
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
# To interate through windows with space and backspace
bind BSpace previous-window
bind Space next-window
bind n next-window
bind N previous-window
# Jump to window with bell
bind c-x next-window -a
bind X previous-window -a
# Scroll wheel the right way (with recent tmux)
# If scrolled Pane is NOT in alternate, AND it's not in (copy)mode, then start copy mode
bind -n WheelUpPane if -Ft= '#{pane_in_mode}' 'send-keys -M' 'if -Ft= "#{alternate_on}" "send-keys -M" "copy-mode -e -t="'
bind -n WheelDownPane select-pane -t= \; send-keys -M
# Don't send mouse clicks to apps
bind -n MouseDown1Pane select-pane -t=
bind -n MouseUp1Pane send-keys "" # NOP
# Dont try to drag-scroll
bind -n MouseDragEnd1Pane send-keys "" # NOP
# Do not auto-copy on mouse drag end
unbind -T copy-mode-vi MouseDragEnd1Pane
# Double-clicking starts selection of word (both normal end copy-mode-vi)
bind -n DoubleClick1Pane copy-mode -t= \; send-keys -X select-word
bind -T copy-mode-vi DoubleClick1Pane send-keys -X select-word
# Drag start in normal mode also starts selection of word
bind -n MouseDrag1Pane copy-mode -t= \; send-keys -X select-word
# Toggle monitoring activity and/or silence. Have the same keys as `screen`
bind "#" set -w monitor-activity
bind _ if -F '#{monitor-silence}' 'set -w monitor-silence 0' 'set -w monitor-silence 30'
# Global default
set -g monitor-activity off
# Clear pane
bind r send-keys -R \; clear-history \; refresh-client \; send-keys ^L
# Kill pane/window
bind x confirm-before -p "kill-pane #P? (y/n)" kill-pane
# Log pane output to file (toggle)
bind | pipe-pane -o 'cat >>~/Desktop/tmux-output.#S.#I.#P.#W.txt'
# Hardcopy pane visible
bind y command-prompt -1 -p "Hardcopy VISIBLE pane in (a)scii or (c)olor?" "if-shell -F '#{==:%%,a}' 'capture-pane -J -b hardcopy' 'capture-pane -e -b hardcopy' ; save-buffer -b hardcopy '$HOME/Desktop/tmux-visible.#S.#I.#P.#W.#{client_activity}.txt' ; delete-buffer -b hardcopy ; display Saved"
# Hardcopy pane history
bind Y command-prompt -1 -p "Hardcopy HISTORY of pane in (a)scii or (c)olor?" "if-shell -F '#{==:%%,a}' 'capture-pane -S - -J -b hardcopy' 'capture-pane -S - -e -J -b hardcopy' ; save-buffer -b hardcopy '$HOME/Desktop/tmux-history.#S.#I.#P.#W.#{client_activity}.txt' ; delete-buffer -b hardcopy ; display Saved"
# Reload tmux config
bind R source-file ~/.tmux.conf\; display "Config reloaded!"
# Inject bash config. Easiest key, used all the time
bind c-w load-buffer -b staticsendbuf ~/.kkrc/inject-bash.txt \; paste-buffer -d -b staticsendbuf
# Inject bash config as if BROADCAST to all panes of current window.
bind W load-buffer -b staticsendbuf ~/.kkrc/inject-bash.txt \; run-shell -b 'for a in $(tmux list-panes -F \#\D); do tmux paste-buffer -t "$a" -b staticsendbuf; done; tmux delete-buffer staticsendbuf; exit 0'
# Inject minimalist ash config. Second easiest key, used a lot
bind c-e load-buffer -b staticsendbuf ~/.kkrc/inject-ash.txt \; paste-buffer -d -b staticsendbuf
# For further use:
#bind "^" usable
#bind "\\" usable
#bind "@" usable
#bind "%" usable (default: split)
#bind "!" usable (default: break-pane)
#bind "\$" usable
#bind "&" usable (default: kill-pane, but we have "X" instead)
#bind "/" usable
#bind "-" usable (default: delete-buffer)
#bind "+" usable
#bind "*" usable
#bind "d" usable (default: detach)
#bind "e" usable
#bind "g" usable
#bind "B" usable
#bind "F" usable
#bind "G" usable
#bind "I" usable
#bind "Q" usable
#bind "T" usable
#bind "T" usable
#bind "Z" usable
#bind "c-c" usable
#bind "c-d" usable
#bind "c-f" usable
#bind "c-g" usable
#bind "c-n" usable
#bind "c-s" usable
#bind "c-t" usable
#bind "c-u" usable
#bind "c-v" usable
#bind "c-y" usable
# Switch to alternate table called "inject". Trigger with: CTRL-Q CTRL-R <key>
bind "c-r" switch-client -T inject
# Paste numbered registers. Set them with:
# set-buffer -b 1 "...\n", or using "<1-9> (like buffer selection in VI) in copy-mode
bind -T inject "1" paste-buffer -b 1
bind -T inject "2" paste-buffer -b 2
bind -T inject "3" paste-buffer -b 3
bind -T inject "4" paste-buffer -b 4
bind -T inject "5" paste-buffer -b 5
bind -T inject "6" paste-buffer -b 6
bind -T inject "7" paste-buffer -b 7
bind -T inject "8" paste-buffer -b 8
bind -T inject "9" paste-buffer -b 9
# Show possible keys in table "inject"
bind -T inject "?" list-keys -T inject
# Load tmux.local
bind -T inject "0" source-file ~/.tmux.local
# Inject vim config
bind -T inject "v" load-buffer -b staticsendbuf ~/.kkrc/inject-vim.txt \; paste-buffer -d -b staticsendbuf
# Inject GNU Screen config
bind -T inject "s" load-buffer -b staticsendbuf ~/.kkrc/inject-screen.txt \; paste-buffer -d -b staticsendbuf
# Change GNU screen colors from blue to red (to visually indicate a PROD system)
bind -T inject "S" load-buffer -b staticsendbuf ~/.kkrc/inject-screen-red.txt \; paste-buffer -d -b staticsendbuf
# Change GNU screen colors to visually indicate whatever you think it should
bind -T inject "c-s" load-buffer -b staticsendbuf ~/.kkrc/inject-screen-3rd.txt \; paste-buffer -d -b staticsendbuf
# Inject psql config
bind -T inject "p" load-buffer -b staticsendbuf ~/.kkrc/.psqlrc \; paste-buffer -d -b staticsendbuf
# Inject proxy environment variables
bind -T inject "P" send-keys " export http_proxy=http://127.0.0.1:8888/; export https_proxy=\$http_proxy" enter
# Inject "lineinfile" command (poor man's Ansible)
bind -T inject "c-l" load-buffer -b staticsendbuf ~/.kkrc/inject-func-lineinfile.txt \; paste-buffer -d -b staticsendbuf
# Inject "hl" command to highlight grep, tail etc
bind -T inject "h" load-buffer -b staticsendbuf ~/.kkrc/inject-func-hl.txt \; paste-buffer -d -b staticsendbuf
# Which OS is this again?
bind -T inject "o" send-keys " cat /etc/os-release; systemd-detect-virt" enter
# For CentOS and other ancient systems
bind -T inject "Q" send-keys " unset QUOTING_STYLE" enter
# Inject SSH_AUTH_SOCK to GNU screen. Used in conjunction with the SSH_AUTH_SOCK passing in the injected .bashrc
bind -T inject "a" send-keys C-a ":paste s" enter enter
# Inject docker-based tools.
bind -T inject "d" load-buffer -b staticsendbuf ~/.kkrc/inject-dockers.txt \; paste-buffer -d -b staticsendbuf
# Poor man's "xxd", with od.
bind -T inject "z" send-keys "od -v -A none -t x1 -w64 <"
# Poor man's "xxd", with hexdump
bind -T inject "c-z" send-keys "hexdump -v -e '64/1 \" %02x\" \"\\n\"' <"
# Poor man's "xxd -r" (reverse the above two)
bind -T inject "Z" send-keys '(tr -d "\r" | sed -E "s/ +$//g" | sed -E "s/ +/\\\\\\\\x/g" | while read x; do printf "${x}"; done) >binaryfile <'
# Painful, but apt upgrade now needs a hotkey, because of the NEEDRESTART stupidity
bind -T inject "u" send-keys 'sudo $EAT apt-get update && sudo $EAT NEEDRESTART_MODE=a apt-get upgrade -y'
# Get prettyping
bind -T inject "c-p" send-keys ' wget -qO ./prettyping https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping && chmod 755 prettyping' enter './prettyping 1.1.1.1'
# Better "set -x" prompt
bind -T inject "x" send-keys "export PS4=$'+\\tLine \$LINENO at $(date -Iseconds): '" enter
# Injects that do CHANGE the remote system.
# The main purpose of these shortcuts is to quickly set up ephemeral dev-VMs.
# Thus we use eatmydata to speed things up (especially on btrfs and xfs) and don't care about safety.
# Add ssh public key to authorized_keys. Create dir if necessary, take care of permissions
set -s command-alias[101] setup_ssh_key="send-keys \" (umask 077; mkdir ~/.ssh 2>/dev/null; echo >>~/.ssh/authorized_keys '\" \; load-buffer -b staticsendbuf ~/.ssh/id_ed25519.pub \; paste-buffer -d -s '' -b staticsendbuf \; send-keys \"')\" enter"
# Install must-have packages on the remote system (Debian & derivatives)
BASIC="man less psmisc screen htop curl wget bash-completion dnsutils git tig socat rsync zip unzip vim-nox unattended-upgrades"
set -s command-alias[104] setup_basics_eatmydata="send-keys ' until sudo apt-get update; do sleep 1; done; [ -f /usr/bin/eatmydata ] || until sudo NEEDRESTART_MODE=a apt-get install -y eatmydata; do sleep 1; done; export EAT=eatmydata; until sudo NEEDRESTART_MODE=a eatmydata apt-get install -y less $BASIC; do sleep 1; done;' #enter"
# Install .kkrc
set -s command-alias[105] setup_kkrc="send-keys \" git clone https://github.com/kkovacs/kkrc/ ~/.kkrc; ~/.kkrc/install.sh; . ~/.bashrc\" enter"
# Poor server's Ansible. :)
set -s command-alias[106] setup_bashrc="load-buffer -b staticsendbuf ~/.kkrc/inject-func-lineinfile.txt \; paste-buffer -d -b staticsendbuf \; load-buffer -b staticsendbuf ~/.kkrc/inject-setup-bashrc.txt \; paste-buffer -d -b staticsendbuf"
# Debian/Ubuntu: put warning about system being PROD in /etc/debian_chroot, becase even the default bashrc displays it (both root and user).
set -s command-alias[107] setup_prodwarning="send-keys ' printf \"\\033[00;31mPRODUCTION SERVER\\033[00m\" >/etc/debian_chroot' enter"
# Install must-have packages on the remote system (RedHat & derivatives)
set -s command-alias[108] setup_centos="send-keys ' sudo yum install -y epel-release && sudo yum install -y less psmisc screen htop curl wget bash-completion bind-utils util-linux git tig socat rsync vim zip unzip' #enter"
# Install docker & docker-compose
# DO NOT USE THIS FOR PRODUCTION, we're cheating: to avoid having to long in-out to obtain the "docker" group, we pre-create the docker group with the current user's GID.
set -s command-alias[109] setup_docker="send-keys ' [[ \${GROUPS[0]} -gt 0 ]] && sudo groupadd -og \${GROUPS[0]} docker || true && until sudo NEEDRESTART_MODE=a \$EAT apt-get install -y docker.io docker-compose docker-compose-v2; do sleep 1; done' enter"
# nodejs install
set -s command-alias[110] setup_node_current="send-keys ' sudo snap install node --classic --channel=22' enter"
set -s command-alias[102] setup_node_lts="send-keys ' sudo snap install node --classic --channel=20' enter"
# Install PHP & composer
set -s command-alias[111] setup_php="send-keys ' sudo NEEDRESTART_MODE=a \$EAT apt-get install -y $BASIC php-cli php-gd php-mbstring php-dom php-xml php-zip php-curl php-intl php-mysql php-pgsql php-sqlite3 php-xdebug && (curl -sS https://getcomposer.org/installer | sudo NEEDRESTART_MODE=a php -- --install-dir=/usr/local/bin --filename=composer)' enter"
# Minikube but running on local docker (for setting up playground/dev VMs)
set -s command-alias[112] setup_minikube="load-buffer -b staticsendbuf ~/.kkrc/inject-setup-minikube.txt \; paste-buffer -d -b staticsendbuf"
# Mysql, without any real password protection (default oracle password as cultural nod)
set -s command-alias[113] setup_mysql="send-keys ' sudo debconf-set-selections <<< \"mysql-server mysql-server/root_password password tiger\"; sudo debconf-set-selections <<< \"mysql-server mysql-server/root_password_again password tiger\"; sudo NEEDRESTART_MODE=a \$EAT apt-get install -y mysql-server' enter"
# Golang latest
set -s command-alias[114] setup_golang="send-keys ' type -p go || (cd /tmp; FNAME=\$(curl -s https://go.dev/dl/ | grep -om 1 \"go[[:digit:].]\\+linux-$(dpkg --print-architecture)\\.tar\\.gz\"|head -1); wget -nc \"https://go.dev/dl/\$FNAME\"; cd /usr/local/; sudo tar zxf \"/tmp/\$FNAME\"; sudo find /usr/local/go/bin/ -type f -executable -exec ln -s \"{}\" /usr/local/bin/ \\; );' enter"
# PostgreSQL
set -s command-alias[115] setup_postgres="send-keys ' sudo NEEDRESTART_MODE=a \$EAT apt-get install -y postgresql; export PGUSER=root PGPASSWORD=tiger PGHOST=127.0.0.1; printf \"\$PGPASSWORD\\n\$PGPASSWORD\" | sudo su - postgres -c \"createuser --superuser --pwprompt \\\"\$PGUSER\\\"\"' enter"
# Inject an .editorconfig
set -s command-alias[116] setup_editorconfig="send-keys ' cat >.editorconfig <<\"EOF\"' enter ; load-buffer -b staticsendbuf ~/.kkrc/.editorconfig ; paste-buffer -d -b staticsendbuf ; send-keys 'EOF' enter"
# Set up remote ~/.screenrc
set -s command-alias[117] setup_screenrc="send-keys ' cat >~/.screenrc <<\"EOF\"' enter ; load-buffer -b staticsendbuf ~/.kkrc/.screenrc ; paste-buffer -d -b staticsendbuf ; send-keys 'EOF' enter"
# Set up vim-go
set -s command-alias[118] setup_vim_go="send-keys ' git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go; vim -e -c GoInstallBinaries -c q' enter"
# Set up vim IDE
set -s command-alias[119] setup_vim_tagbar="send-keys ' git clone https://github.com/preservim/tagbar.git ~/.vim/pack/kkrc/start/tagbar; sudo NEEDRESTART_MODE=a apt install -y universal-ctags' enter"
# Gosec
set -s command-alias[120] setup_gosec="send-keys ' go install github.com/securego/gosec/v2/cmd/gosec@latest' enter '~/go/bin/gosec -r'"
# PHPCS
set -s command-alias[121] setup_phpcs="send-keys ' composer global require --dev squizlabs/php_codesniffer' enter '~/.config/composer/vendor/bin/phpcs'"
# Larastan
set -s command-alias[122] setup_phpstan="send-keys ' composer global require --dev phpstan/phpstan' enter '~/.config/composer/vendor/bin/phpstan analyse'"
# Shellcheck
set -s command-alias[123] setup_shellcheck="send-keys ' wget -qO- \"https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.$(uname -m).tar.xz\" | tar -xJv --strip 1 shellcheck-stable/shellcheck' enter './shellcheck '"
# semgrep
# XXX If apt actually installs, it "eats" the pre-typed command.
set -s command-alias[124] setup_semgrep="send-keys ' sudo NEEDRESTART_MODE=a apt-get install -y python3-pip && pip install semgrep' enter '~/.local/bin/semgrep --config=auto'"
set -s command-alias[125] get_adminer="send-keys ' wget -qO /tmp/adminer-en.zip https://download.adminerevo.org/latest/adminer/adminer-en.zip && unzip /tmp/adminer-en.zip && mv adminer-en.php adminer.php' enter"
set -s command-alias[126] setup_duckdb="load-buffer -b staticsendbuf ~/.kkrc/inject-func-whichcpu.txt ; paste-buffer -d -b staticsendbuf ; send-keys ' wget -qO /tmp/duckdb.zip https://github.com/duckdb/duckdb/releases/latest/download/duckdb_cli-linux-$(whichcpu amd64 aarch64).zip && sudo unzip -o /tmp/duckdb.zip -d /usr/local/bin/' enter"
set -s command-alias[127] setup_python_venv="send-keys ' sudo apt-get install -y python3-venv && python3 -m venv .venv; . .venv/bin/activate' enter"
set -s command-alias[128] setup_frankenphp="send-keys ' sudo wget -qO /usr/local/bin/frankenphp https://github.com/dunglas/frankenphp/releases/latest/download/frankenphp-linux-$(uname -m) && sudo chmod 755 /usr/local/bin/frankenphp' enter"
set -s command-alias[129] setup_composer="send-keys ' sudo wget -qO /usr/local/bin/composer https://github.com/composer/composer/releases/latest/download/composer.phar && sudo chmod 755 /usr/local/bin/composer' enter"
set -s command-alias[130] setup_static_php_cli="send-keys ' wget -qO- https://dl.static-php.dev/static-php-cli/bulk/php-8.3.9-cli-linux-$(uname -m).tar.gz | sudo tar xz --no-same-owner -C /usr/local/bin/' enter"
set -s command-alias[131] get_pgweb="load-buffer -b staticsendbuf ~/.kkrc/inject-func-whichcpu.txt ; paste-buffer -d -b staticsendbuf ; send-keys ' wget -qO /tmp/pgweb.zip https://github.com/sosedoff/pgweb/releases/download/v0.16.0/pgweb_linux_$(whichcpu amd64 arm64).zip && sudo unzip -o /tmp/pgweb.zip -d /usr/local/bin/' enter"
set -s command-alias[132] setup_jupyterlab="send-keys 'pip install jupyterlab jupysql itables psycopg2-binary jupyterlab-git plotly ipywidgets duckdb duckdb-engine magic-duckdb && while true; do jupyter lab --ip=0.0.0.0 --port=80; sleep 1; done' enter"
# Install menu. DONT USE: "j", "k", "q" PLEASE!
bind -T inject "c-r" display-menu -T " Install... " -x 4 -y P \
"kkrc" "" setup_kkrc \
"basic+kkrc" "r" "send-keys ' time cat <<\"EOF\" | bash' enter '[ ! -f /usr/bin/tig ] && {' ; setup_basics_eatmydata ; send-keys ' } ; [ ! -d ~/.kkrc ] && {' ; setup_kkrc ; send-keys '}' enter 'EOF' enter '. ~/.bashrc' enter" \
"authorized_keys" "K" setup_ssh_key \
"apt ..." "a" setup_basics_eatmydata \
"yum ..." "y" setup_centos \
"Drop .screenrc" "S" setup_screenrc \
"Drop .editorconfig" "E" setup_editorconfig \
"Modify .bashrc" "B" setup_bashrc \
"Setup PROD warn" "W" setup_prodwarning \
"Setup vim-go" "G" setup_vim_go \
"Setup vim-tagbar" "T" setup_vim_tagbar \
"" \
"Install php" "p" setup_php \
"Install php composer" "c" setup_composer \
"Download adminer" "A" get_adminer \
"Download pgweb" "w" get_pgweb \
"Download frankenphp" "f" setup_frankenphp \
"Download static-php-cli" "s" setup_static_php_cli \
"Install go" "g" setup_golang \
"Install nodejs LTS" "n" setup_node_lts \
"Install nodejs current" "N" setup_node_current \
"Install python venv" "V" setup_python_venv \
"" \
"Install mysql" "m" setup_mysql \
"Install postgres" "P" setup_postgres \
"Install duckdb" "D" setup_duckdb \
"Install docker" "d" setup_docker \
"Install minikube" "" setup_minikube \
"" \
"Install gosec" "" setup_gosec \
"Install phpcs" "" setup_phpcs \
"Install phpstan" "" setup_phpstan \
"Install semgrep" "" setup_semgrep \
"Install shellcheck" "" setup_shellcheck \
"" \
"php+node+mysql" "1" "send-keys ' time cat <<\"EOF\" | bash' enter ; setup_basics_eatmydata ; setup_kkrc ; setup_php ; setup_node_lts ; setup_mysql ; send-keys 'EOF' enter '. ~/.bashrc' enter" \
"php+node+psql" "2" "send-keys ' time cat <<\"EOF\" | bash' enter ; setup_basics_eatmydata ; setup_kkrc ; setup_php ; setup_node_lts ; setup_postgres ; send-keys 'EOF' enter '. ~/.bashrc' enter" \
"php+node+docker" "3" "send-keys ' time cat <<\"EOF\" | bash' enter ; setup_basics_eatmydata ; setup_kkrc ; setup_php ; setup_node_lts ; setup_docker ; send-keys 'EOF' enter '. ~/.bashrc' enter" \
"go+vim" "4" "send-keys ' time cat <<\"EOF\" | bash' enter ; setup_basics_eatmydata ; setup_kkrc ; setup_golang ; setup_vim_tagbar ; setup_vim_go ; send-keys 'EOF' enter '. ~/.bashrc' enter" \
"go+vim+psql" "5" "send-keys ' time cat <<\"EOF\" | bash' enter ; setup_basics_eatmydata ; setup_kkrc ; setup_golang ; setup_postgres ; setup_vim_tagbar ; setup_vim_go ; send-keys 'EOF' enter '. ~/.bashrc' enter" \
"go+vim+psql+node" "6" "send-keys ' time cat <<\"EOF\" | bash' enter ; setup_basics_eatmydata ; setup_kkrc ; setup_golang ; setup_node_lts ; setup_postgres ; setup_vim_tagbar ; setup_vim_go ; send-keys 'EOF' enter '. ~/.bashrc' enter" \
"go+vim+docker" "7" "send-keys ' time cat <<\"EOF\" | bash' enter ; setup_basics_eatmydata ; setup_kkrc ; setup_golang ; setup_docker ; setup_vim_tagbar ; setup_vim_go ; send-keys 'EOF' enter '. ~/.bashrc' enter" \
"franken+php+node" "8" "send-keys ' time cat <<\"EOF\" | bash' enter ; setup_basics_eatmydata ; setup_kkrc ; setup_frankenphp ; setup_static_php_cli ; setup_composer ; setup_node_lts ; send-keys 'EOF' enter '. ~/.bashrc' enter" \
"python+jupyterlab" "9" "send-keys ' time cat <<\"EOF\" | bash' enter ; setup_python_venv ; setup_jupyterlab ; send-keys 'EOF' enter '. ~/.bashrc' enter" \
# Local commands:
#source-file -q ~/.tmux.local