diff options
| -rw-r--r-- | core/tmux.conf | 29 | ||||
| -rw-r--r-- | core/vimrc | 37 |
2 files changed, 52 insertions, 14 deletions
diff --git a/core/tmux.conf b/core/tmux.conf index 97084f1..2a0e161 100644 --- a/core/tmux.conf +++ b/core/tmux.conf | |||
| @@ -23,19 +23,24 @@ bind -r J resize-pane -D 1 | |||
| 23 | bind -r K resize-pane -U 1 | 23 | bind -r K resize-pane -U 1 |
| 24 | bind -r L resize-pane -R 1 | 24 | bind -r L resize-pane -R 1 |
| 25 | 25 | ||
| 26 | # v to start selection, y to yank (like vim) | 26 | # ===== Shared clipboard: RAM file /dev/shm/clip/buf on CLIP_HOST ===== |
| 27 | %hidden CLIP_HOST="root@p.noml.ch" | ||
| 28 | # One persistent ssh link (opens on first use, one key touch). | ||
| 29 | # Close it: ssh -O exit -o ControlPath=~/.ssh/cm-%C <CLIP_HOST> | ||
| 30 | %hidden CLIP="ssh -o ControlMaster=auto -o ControlPersist=yes -o ControlPath=~/.ssh/cm-%C -o ServerAliveInterval=30 -o ConnectTimeout=3 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR $CLIP_HOST" | ||
| 31 | # push (yank): copy mode v to select, then y / Enter / mouse drag | ||
| 32 | %hidden YANK="$CLIP 'umask 077; mkdir -p /dev/shm/clip && cat >/dev/shm/clip/new && mv /dev/shm/clip/new /dev/shm/clip/buf'" | ||
| 27 | bind-key -T copy-mode-vi v send-keys -X begin-selection | 33 | bind-key -T copy-mode-vi v send-keys -X begin-selection |
| 28 | # macOS: pbcopy. Linux: wl-copy/xclip when usable, else just drain (tmux's own | 34 | bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear "$YANK" |
| 29 | # buffer + set-clipboard/OSC 52 still apply). Netcat send is the same on both. | 35 | bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "$YANK" |
| 30 | if-shell 'uname | grep -q Darwin' { | 36 | bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "$YANK" |
| 31 | bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear "bash -c 'tee >(pbcopy) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'" | 37 | # pull (paste): prefix + ] fetches the buffer into tmux, then pastes it; |
| 32 | bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "bash -c 'tee >(pbcopy) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'" | 38 | # no buffer on CLIP_HOST yet (exit 3, e.g. after its reboot) = paste tmux's own buffer |
| 33 | bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "bash -c 'tee >(pbcopy) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'" | 39 | bind-key ] run-shell "f=\$(mktemp); $CLIP '[ -f /dev/shm/clip/buf ] || exit 3; cat /dev/shm/clip/buf' >\$f; r=\$?; [ \$r -eq 0 ] && tmux load-buffer \$f; rm -f \$f; [ \$r -eq 0 ] || [ \$r -eq 3 ] && tmux paste-buffer" |
| 34 | } { | 40 | # ===== end shared clipboard ===== |
| 35 | # Linux only: true-color regardless of what TERM the outer terminal/distro sets | 41 | |
| 42 | # Linux only: true-color regardless of what TERM the outer terminal/distro sets | ||
| 43 | if-shell 'uname | grep -q Darwin' {} { | ||
| 36 | set -g default-terminal "tmux-256color" | 44 | set -g default-terminal "tmux-256color" |
| 37 | set -ga terminal-overrides ",*256col*:Tc" | 45 | set -ga terminal-overrides ",*256col*:Tc" |
| 38 | bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear "bash -c 'tee >(wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || cat >/dev/null) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'" | ||
| 39 | bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "bash -c 'tee >(wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || cat >/dev/null) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'" | ||
| 40 | bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "bash -c 'tee >(wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || cat >/dev/null) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'" | ||
| 41 | } | 46 | } |
| @@ -1,5 +1,6 @@ | |||
| 1 | " One vimrc for Mac and Linux. Source of truth: /Users/xs/dev_env/core/vimrc | 1 | " One vimrc for Mac and Linux. Source of truth: /Users/xs/dev_env/core/vimrc |
| 2 | " Mac: cp core/vimrc ~/.vimrc Linux: sudo bash core/vim.sh (copies it to /etc/vimrc or /etc/vim/vimrc) | 2 | " Mac: cp core/vimrc ~/.vimrc Linux: sudo bash core/vim.sh (copies it to /etc/vimrc or /etc/vim/vimrc) |
| 3 | set nocompatible " /etc/vimrc is read before vim leaves vi mode; without this \ continuations and <leader> break | ||
| 3 | " gt: go to next tab (right, wraps) | 4 | " gt: go to next tab (right, wraps) |
| 4 | " gT: go to previous tab (left, wraps) | 5 | " gT: go to previous tab (left, wraps) |
| 5 | " 2gt: go to tab number 2 (counted from 1 at the left) | 6 | " 2gt: go to tab number 2 (counted from 1 at the left) |
| @@ -53,10 +54,42 @@ nnoremap <silent> <leader>f :<C-U>LspDocumentFormat<CR>| " \f: format file | |||
| 53 | nnoremap <silent> <leader>em :<C-U>call ExpandMacro()<CR>| " \em: expand macro under cursor | 54 | nnoremap <silent> <leader>em :<C-U>call ExpandMacro()<CR>| " \em: expand macro under cursor |
| 54 | 55 | ||
| 55 | 56 | ||
| 56 | augroup netcat_clipboard | 57 | " ===== Shared clipboard: RAM file /dev/shm/clip/buf on g:clip_host (same as tmux.conf) ===== |
| 58 | let g:clip_host = 'root@p.noml.ch' | ||
| 59 | " One persistent ssh link (opens on first use, one key touch). | ||
| 60 | let g:clip = ['ssh', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=yes', '-o', 'ControlPath=~/.ssh/cm-%C', '-o', 'ServerAliveInterval=30', '-o', 'ConnectTimeout=3', '-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'LogLevel=ERROR', g:clip_host] | ||
| 61 | " push (yank): every yank or delete sends @" in a background job | ||
| 62 | augroup ssh_clipboard | ||
| 57 | au! | 63 | au! |
| 58 | au TextYankPost * call system("echo " . shellescape(@") . " | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1 &") | 64 | au TextYankPost * let g:clip_job = job_start(g:clip + ['umask 077; mkdir -p /dev/shm/clip && cat >/dev/shm/clip/new && mv /dev/shm/clip/new /dev/shm/clip/buf'], {'in_io': 'pipe', 'out_io': 'null', 'err_io': 'null'}) | call ch_sendraw(g:clip_job, @") | call ch_close_in(g:clip_job) |
| 59 | augroup END | 65 | augroup END |
| 66 | " pull (paste): every p P gp gP ]p [p (normal) and p P (visual) first fetches the buffer into @". | ||
| 67 | " Waits up to 3 s for a pending push, then up to 3 s for the fetch (perl alarm kills ssh); | ||
| 68 | " no buffer on g:clip_host yet (exit 3, e.g. after its reboot) = normal local paste; | ||
| 69 | " any other failure prints a message and skips the paste. Counts and "x register prefixes still work. | ||
| 70 | function! ClipPull() abort | ||
| 71 | let l:i = 0 | ||
| 72 | while exists('g:clip_job') && job_status(g:clip_job) ==# 'run' && l:i < 30 | ||
| 73 | sleep 100m | ||
| 74 | let l:i += 1 | ||
| 75 | endwhile | ||
| 76 | let l:out = system("perl -e 'alarm 3; exec @ARGV' " . join(g:clip) . " '[ -f /dev/shm/clip/buf ] || exit 3; cat /dev/shm/clip/buf'") | ||
| 77 | if v:shell_error == 3 | ||
| 78 | return 1 | ||
| 79 | elseif v:shell_error | ||
| 80 | echohl ErrorMsg | echo 'clip: pull from ' . g:clip_host . ' failed or took >3s, paste skipped' | echohl None | ||
| 81 | return 0 | ||
| 82 | endif | ||
| 83 | call setreg('"', l:out) | ||
| 84 | return 1 | ||
| 85 | endfunction | ||
| 86 | for s:k in ['p', 'P', 'gp', 'gP', ']p', '[p'] | ||
| 87 | execute 'nnoremap <expr> ' . s:k . " ClipPull() ? '" . s:k . "' : ''" | ||
| 88 | endfor | ||
| 89 | for s:k in ['p', 'P'] | ||
| 90 | execute 'xnoremap <expr> ' . s:k . " ClipPull() ? '" . s:k . "' : ''" | ||
| 91 | endfor | ||
| 92 | " ===== end shared clipboard ===== | ||
| 60 | 93 | ||
| 61 | filetype plugin indent on | 94 | filetype plugin indent on |
| 62 | 95 | ||
