Add -g (get) and -x (xclip) flags to pasta

* -g curl's the file from rest -- TODO: implement portable HTTP Get
  client
* -x puts the remote path in the xclipboard (selection clipboard) with
  the xclip command (if installed)
This commit is contained in:
Dylan Lom 2021-03-01 16:19:56 +11:00
parent 139058b9b7
commit 177c5b7ddc
1 changed files with 16 additions and 1 deletions

View File

@ -11,7 +11,7 @@ destdomain="http://p.dlom.cc"
argv0="$0"
usage() {
echo "usage: $argv0 [-p | -c] filename"
echo "usage: $argv0 [-p|-c|-g] [-x] filename"
exit 1
}
@ -19,6 +19,8 @@ while [ "$#" -gt 1 ]; do
case "$1" in
'-p') png='true'; ;;
'-c') concat='true'; ;;
'-g') get='true'; ;;
'-x') xclip='true'; ;;
*) usage ;;
esac
shift
@ -27,6 +29,19 @@ done
name="$1"
[ -z "$name" ] && usage
if truthy "$xclip"; then
command -v xclip > /dev/null \
|| (echo "ERROR: xclip not found" && exit 1) \
&& (echo "$destdomain/$name" | \
tr -d '\n' | \
xclip -selection clipboard)
fi
if truthy "$get"; then
curl "$destdomain/$name"
exit
fi
if truthy "$concat"; then
ssh "$sshdomain" "cat >> $destpath/$name"
else