From bbe55a3f647f07a6b7c9852a499c45d03ac068af Mon Sep 17 00:00:00 2001 From: xs Date: Thu, 5 Nov 2026 10:45:29 +0800 Subject: core: shared clipboard over ssh to root@p.noml.ch tmux.conf and vimrc push yanks to /dev/shm/clip/buf on CLIP_HOST (root@p.noml.ch) and pull before every paste (tmux prefix+], every vim p variant, 3 s limit, local paste when no buffer exists yet). One persistent ssh link per machine (ControlPersist=yes, ControlPath ~/.ssh/cm-%C), host key not checked. Replaces the openssl+netcat sender. vimrc: set nocompatible so /etc/vimrc parses \ continuations and . --- core/tmux.conf | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'core/tmux.conf') 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 bind -r K resize-pane -U 1 bind -r L resize-pane -R 1 -# v to start selection, y to yank (like vim) +# ===== Shared clipboard: RAM file /dev/shm/clip/buf on CLIP_HOST ===== +%hidden CLIP_HOST="root@p.noml.ch" +# One persistent ssh link (opens on first use, one key touch). +# Close it: ssh -O exit -o ControlPath=~/.ssh/cm-%C +%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" +# push (yank): copy mode v to select, then y / Enter / mouse drag +%hidden YANK="$CLIP 'umask 077; mkdir -p /dev/shm/clip && cat >/dev/shm/clip/new && mv /dev/shm/clip/new /dev/shm/clip/buf'" bind-key -T copy-mode-vi v send-keys -X begin-selection -# macOS: pbcopy. Linux: wl-copy/xclip when usable, else just drain (tmux's own -# buffer + set-clipboard/OSC 52 still apply). Netcat send is the same on both. -if-shell 'uname | grep -q Darwin' { - 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'" - 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'" - 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'" -} { - # Linux only: true-color regardless of what TERM the outer terminal/distro sets +bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear "$YANK" +bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "$YANK" +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "$YANK" +# pull (paste): prefix + ] fetches the buffer into tmux, then pastes it; +# no buffer on CLIP_HOST yet (exit 3, e.g. after its reboot) = paste tmux's own buffer +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" +# ===== end shared clipboard ===== + +# Linux only: true-color regardless of what TERM the outer terminal/distro sets +if-shell 'uname | grep -q Darwin' {} { set -g default-terminal "tmux-256color" set -ga terminal-overrides ",*256col*:Tc" - 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'" - 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'" - 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'" } -- cgit