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; }