mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-05 01:46:46 +01:00
Enhance clipboard functionality for various environments
Added clipboard functions for SSH and terminal emulators.
This commit is contained in:
parent
dca16e8f9a
commit
d6552d8887
1 changed files with 17 additions and 0 deletions
|
|
@ -54,6 +54,23 @@ function detect-clipboard() {
|
||||||
if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then
|
if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | pbcopy; }
|
function clipcopy() { cat "${1:-/dev/stdin}" | pbcopy; }
|
||||||
function clippaste() { pbpaste; }
|
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
|
elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; }
|
function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; }
|
||||||
function clippaste() { cat /dev/clipboard; }
|
function clippaste() { cat /dev/clipboard; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue