q.sh/q-clipboard

31 lines
672 B
Text
Raw Normal View History

#!/bin/sh
2021-10-11 08:44:40 +00:00
2023-05-14 19:24:27 +00:00
ENV_cat=cat
ENV_tac=tac
ENV_base64=base64
ENV_wl_copy=wl-copy
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
2023-05-14 19:24:27 +00:00
$ENV_cat ~/.clipboard.txt | $ENV_tac
fi
2021-10-11 08:44:40 +00:00
elif [[ "$1" == "--complete" ]]; then
shift
if [[ -f ~/.clipboard.txt ]]; then
2023-05-14 19:24:27 +00:00
$ENV_cat ~/.clipboard.txt | $ENV_tac
fi
2021-10-11 08:44:40 +00:00
elif [[ "$1" == "--preview" ]]; then
shift
2023-05-14 19:24:27 +00:00
echo "$1" | $ENV_base64 -d
2021-10-11 08:44:40 +00:00
elif [[ "$1" == "--run" ]]; then
shift
2023-05-14 19:24:27 +00:00
TEXT="$(echo "$1" | $ENV_base64 -d)"
echo "$TEXT"
2023-05-14 19:24:27 +00:00
echo -n "$TEXT" | (nohup $ENV_wl_copy -n 2>/dev/null &)
2021-10-11 08:44:40 +00:00
else
echo "Unexpected arguments: $@"
2021-10-11 08:44:40 +00:00
fi