Files
scripts/shell/clipsend.sh
2025-09-18 11:35:56 +02:00

23 lines
499 B
Bash
Executable File

#!/bin/sh
REMOTE_FILE="~/clip"
SEPARATOR='---xx---'
case "$1" in
append)
clipboard_content=$(wl-paste)
formatted_content="$SEPARATOR\n$clipboard_content\n"
echo -e "$formatted_content" | ssh bi "cat >> $REMOTE_FILE"
echo "Clipboard contents appended to remote file."
;;
retrieve)
lines=$(ssh bi "tac $REMOTE_FILE | awk '/$SEPARATOR/ {exit} {print}' | tac")
echo -e "$lines" | wl-copy
echo "Last entry copied to clipboard."
wtype $lines
;;
*)
echo "Usage: $0 {append|retrieve}"
;;
esac