Make clip agnostic to clipboard.

This commit is contained in:
Sebastian Bugge 2025-09-21 17:15:18 +02:00
parent d8d0a04556
commit fa7d18e179
Signed by: kaholaz
GPG key ID: 2EFFEDEE03519691

View file

@ -64,7 +64,28 @@ itks() {
xdg-open "https://google.com/search?q=$1+site%3Aitk.samfundet.no" xdg-open "https://google.com/search?q=$1+site%3Aitk.samfundet.no"
} }
alias clip="wl-copy" clip() {
input=$(cat)
if [ -n "$WAYLAND_DISPLAY" ] && command -v wl-copy >/dev/null 2>&1; then
printf "%s" "$input" | wl-copy
return
fi
if [ -n "$DISPLAY" ] && command -v xclip >/dev/null 2>&1; then
printf "%s" "$input" | xclip -selection clipboard
return
fi
if [ -n "$TERM" ]; then
esc="$(printf "%s" "$input" | base64 | tr -d '\r\n')"
printf "\033]52;c;%s\a" "$esc"
return
fi
echo "No clipboard method available" >&2
return 1
}
dchmod () { dchmod () {
find $2 -type d -exec chmod $1 {} + find $2 -type d -exec chmod $1 {} +