summaryrefslogtreecommitdiffstats
path: root/fb-client/fb-0.6.1
diff options
context:
space:
mode:
Diffstat (limited to 'fb-client/fb-0.6.1')
-rw-r--r--fb-client/fb-0.6.180
1 files changed, 80 insertions, 0 deletions
diff --git a/fb-client/fb-0.6.1 b/fb-client/fb-0.6.1
new file mode 100644
index 0000000..06dd87e
--- /dev/null
+++ b/fb-client/fb-0.6.1
@@ -0,0 +1,80 @@
+#!/bin/bash
+#----------------------------------------------------
+# Author: Florian "Bluewind" Pritz <flo@xssn.at>
+#
+# Licensed under WTFPL v2
+# (see COPYING for full license text)
+#
+#----------------------------------------------------
+# only works if useragent contains libcurl
+# Dependencies: curl
+# Optional: xclip
+#----------------------------------------------------
+
+VERSION="0.6.1"
+
+DELETE=0
+EXTENSION=""
+GET=0
+PASTEBIN="http://paste.xinu.at"
+
+do_upload() {
+ local EXTRA=""
+ if [[ -n $EXTENSION ]]; then
+ EXTRA="-F extension=$EXTENSION"
+ fi
+ URL="$(curl -# -n -L $EXTRA -F "file=@$1" "$PASTEBIN/file/do_upload")"
+ echo $URL
+ echo -n "$URL" | nohup &> /dev/null xclip
+}
+
+read_stdin() {
+ if tty -s; then
+ echo "^C to exit, ^D to send"
+ fi
+ cat > "$1"
+}
+
+help() {
+ echo "fb-client version $VERSION"
+ echo "usage: [cat |] $(basename "$0") [switches] [file(s)|ID(s)]"
+ echo " Upload/nopaste file/stdin to paste.xinu.at and copy URL to clipboard."
+ echo " ~/.netrc: machine paste.xinu.at password PASSWORD"
+ echo ""
+ echo "Switches:"
+ echo " -e EXTENSION extension for default highlighting (e.g. \"diff\")"
+ echo " -d delete the IDs"
+ echo " -g download the IDs and output on stdout (use with care!)"
+ echo " -h this help"
+ exit 0
+}
+
+while getopts ":e:gdh" OPTION; do
+ case $OPTION in
+ e) EXTENSION="$OPTARG";;
+ g) GET=1;;
+ d) DELETE=1;;
+ h) help;;
+ \?) echo "unknown option \"-$OPTARG\"" >&2; exit 1;;
+ :) echo "Option \"-$OPTARG\" needs an argument" >&2; exit 1;;
+ esac
+done
+
+shift $((OPTIND - 1))
+
+TMPDIR="$(mktemp -d "/tmp/fb.XXXXXX")"
+
+if (($# == 0)); then
+ read_stdin "$TMPDIR/stdin"
+ do_upload "$TMPDIR/stdin"
+else
+ for i in "$@"; do
+ if [[ $DELETE == 1 ]]; then
+ curl -n -L "$PASTEBIN/file/delete/$i"
+ elif [[ $GET == 1 ]]; then
+ curl -s -o - "$PASTEBIN/$i"
+ else
+ do_upload $i
+ fi
+ done
+fi