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:
parent
139058b9b7
commit
177c5b7ddc
17
src/pasta
17
src/pasta
|
@ -11,7 +11,7 @@ destdomain="http://p.dlom.cc"
|
||||||
argv0="$0"
|
argv0="$0"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage: $argv0 [-p | -c] filename"
|
echo "usage: $argv0 [-p|-c|-g] [-x] filename"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ while [ "$#" -gt 1 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
'-p') png='true'; ;;
|
'-p') png='true'; ;;
|
||||||
'-c') concat='true'; ;;
|
'-c') concat='true'; ;;
|
||||||
|
'-g') get='true'; ;;
|
||||||
|
'-x') xclip='true'; ;;
|
||||||
*) usage ;;
|
*) usage ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
|
@ -27,6 +29,19 @@ done
|
||||||
name="$1"
|
name="$1"
|
||||||
[ -z "$name" ] && usage
|
[ -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
|
if truthy "$concat"; then
|
||||||
ssh "$sshdomain" "cat >> $destpath/$name"
|
ssh "$sshdomain" "cat >> $destpath/$name"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue