1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2025-12-12 15:34:50 +08:00

Compare commits

...

2 Commits

Author SHA1 Message Date
ha7v
225eb39785
Merge d6552d8887 into 72acd2ca90 2025-12-08 08:33:37 -08:00
ha7v
d6552d8887
Enhance clipboard functionality for various environments
Added clipboard functions for SSH and terminal emulators.
2025-11-14 17:56:59 +08:00

View File

@ -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=$(</dev/stdin)
fi
printf "\e]52;c;%s\a" "$(echo -n "$content" | base64 | tr -d '\n')"
}
function clippaste() {
print "clippaste: reading clipboard via OSC 52 is not supported for security reasons." >&2
return 1
}
elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then
function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; }
function clippaste() { cat /dev/clipboard; }