commit 4bb1818e93a6d0cbcc1654783a1aed7526226177
parent 7b998eab221f41b3e22437196a7afdf26835ca9d
Author: sin <sin@2f30.org>
Date: Fri, 5 Dec 2014 16:50:36 +0000
Allow instant screenshot uploads without temporary files
xscreenshot | if2png | imgurup | xsel -pi
Contributed by z3bra.
Diffstat:
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/imgurup b/imgurup
@@ -4,12 +4,8 @@
# appends links and deletion links to the log
# depends: curl
-# check if all args exist as files
-for F in "$@"; do
- if ! test -f "$F"; then
- echo usage: $(basename $0) image ... && exit 1
- fi
-done
+# use stdin if there is no argument
+test -z "$@" && FILES="-" || FILES="$@"
LOG=$HOME/.imgurlog
@@ -17,7 +13,7 @@ LOG=$HOME/.imgurlog
APIKEY='b3625162d3418ac51a9ee805b1840452'
# upload all
-for IMG in "$@"; do
+for IMG in "$FILES"; do
RESP=$(curl -F "image=@$IMG" -F "key=$APIKEY" \
http://imgur.com/api/upload.xml 2> /dev/null)