From 177c5b7ddcc48255a0a0487d2393693282a451c4 Mon Sep 17 00:00:00 2001 From: Dylan Lom Date: Mon, 1 Mar 2021 16:19:56 +1100 Subject: [PATCH] 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) --- src/pasta | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pasta b/src/pasta index e65175f..c3c4440 100755 --- a/src/pasta +++ b/src/pasta @@ -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