feat: add nosudo

This commit is contained in:
2026-06-25 10:46:07 +08:00
parent 0e7fe55474
commit e8aae9738b
9 changed files with 358 additions and 55 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Copy stdin to the system clipboard (macOS / Linux X11 / Linux Wayland).
set -euo pipefail
if command -v pbcopy >/dev/null 2>&1; then
pbcopy
elif [ "${XDG_SESSION_TYPE:-}" = wayland ] || [ -n "${WAYLAND_DISPLAY:-}" ]; then
if command -v wl-copy >/dev/null 2>&1; then
wl-copy --no-newline
else
echo "clip-copy: wl-copy not found (Wayland session)" >&2
exit 1
fi
elif [ -n "${DISPLAY:-}" ]; then
if command -v xclip >/dev/null 2>&1; then
xclip -selection clipboard
elif command -v xsel >/dev/null 2>&1; then
xsel --clipboard --input
else
echo "clip-copy: xclip or xsel not found (DISPLAY=$DISPLAY)" >&2
exit 1
fi
elif command -v xclip >/dev/null 2>&1; then
xclip -selection clipboard
elif command -v xsel >/dev/null 2>&1; then
xsel --clipboard --input
else
echo "clip-copy: no clipboard tool (pbcopy / wl-copy / xclip / xsel)" >&2
exit 1
fi