From d6552d88874fb5b405d807e8ceab6e5204e731e6 Mon Sep 17 00:00:00 2001 From: ha7v <203988568+ha7v@users.noreply.github.com> Date: Fri, 14 Nov 2025 17:56:59 +0800 Subject: [PATCH] Enhance clipboard functionality for various environments Added clipboard functions for SSH and terminal emulators. --- lib/clipboard.zsh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 5d149f056..113f04585 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -54,6 +54,23 @@ function detect-clipboard() { if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then function clipcopy() { cat "${1:-/dev/stdin}" | pbcopy; } function clippaste() { pbpaste; } + elif [[ -n "$SSH_CONNECTION" || -n "$SSH_TTY" ]] && \ + [[ "$TERM" =~ '^(screen|xterm|iterm|kitty|wezterm|alacritty)' || -n "$TERMINAL_EMULATOR" ]] && \ + (( ${+commands[base64]} )); then + function clipcopy() { + emulate -L zsh + local content + if [[ -n "$1" && -f "$1" ]]; then + content=$(<"$1") + else + content=$(&2 + return 1 + } elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } function clippaste() { cat /dev/clipboard; }