q.sh/q-clipboard

26 lines
507 B
Text
Raw Normal View History

#!/bin/sh
2021-10-11 08:44:40 +00:00
if [[ -z "$@" ]]; then
echo "^c .*$"
2021-10-11 08:44:40 +00:00
elif [[ "$1" == "--hint" ]]; then
shift
if [[ -f ~/.clipboard.txt ]]; then
2024-11-03 23:36:22 +00:00
cat ~/.clipboard.txt | tac
fi
2021-10-11 08:44:40 +00:00
elif [[ "$1" == "--complete" ]]; then
shift
if [[ -f ~/.clipboard.txt ]]; then
2024-11-03 23:36:22 +00:00
cat ~/.clipboard.txt | tac
fi
2021-10-11 08:44:40 +00:00
elif [[ "$1" == "--preview" ]]; then
shift
2024-11-03 23:36:22 +00:00
echo "$1" | base64 -d
2021-10-11 08:44:40 +00:00
elif [[ "$1" == "--run" ]]; then
shift
TEXT="$(echo "$2" | base64 -d)"
echo "$TEXT"
2024-11-03 23:36:22 +00:00
echo -n "$TEXT" | (setsid -f wl-copy)
2021-10-11 08:44:40 +00:00
else
echo "Unexpected arguments: $@"
2021-10-11 08:44:40 +00:00
fi