q.sh/q-clipboard
2024-09-09 02:03:52 +01:00

30 lines
672 B
Bash
Executable file

#!/bin/sh
ENV_cat=cat
ENV_tac=tac
ENV_base64=base64
ENV_wl_copy=wl-copy
if [[ -z "$@" ]]; then
echo "^c .*$"
elif [[ "$1" == "--hint" ]]; then
shift
if [[ -f ~/.clipboard.txt ]]; then
$ENV_cat ~/.clipboard.txt | $ENV_tac
fi
elif [[ "$1" == "--complete" ]]; then
shift
if [[ -f ~/.clipboard.txt ]]; then
$ENV_cat ~/.clipboard.txt | $ENV_tac
fi
elif [[ "$1" == "--preview" ]]; then
shift
echo "$1" | $ENV_base64 -d
elif [[ "$1" == "--run" ]]; then
shift
TEXT="$(echo "$1" | $ENV_base64 -d)"
echo "$TEXT"
echo -n "$TEXT" | (nohup $ENV_wl_copy -n 2>/dev/null &)
else
echo "Unexpected arguments: $@"
fi