owenrusk.dev

dotfiles

shell, editor, ssh.

git clone https://owenrusk.dev/dotfiles.git

dotfiles / bin/clip -rwxr-xr-x · 482 bytes

 1 #!/bin/sh
 2 # stdin to the clipboard, with whatever this machine has
 3 if [ -n "${WAYLAND_DISPLAY:-}" ] && command -v wl-copy >/dev/null 2>&1; then
 4     exec wl-copy
 5 elif [ -n "${DISPLAY:-}" ] && command -v xclip >/dev/null 2>&1; then
 6     exec xclip -selection clipboard
 7 elif [ -n "${SSH_TTY:-}" ]; then
 8     # osc 52: the terminal at the other end does the copying
 9     printf '\033]52;c;%s\a' "$(base64 | tr -d '\n')" > "$SSH_TTY"
10     exit 0
11 fi
12 echo "clip: no clipboard here" >&2
13 exit 1