From b5caa1c3bb8cca2c9e40fc265acea14365e332af Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 9 Jul 2011 16:04:16 +0200 Subject: add a local history; -H option Signed-off-by: Florian Pritz --- fb.in | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'fb.in') diff --git a/fb.in b/fb.in index 3af3b16..05ac03e 100644 --- a/fb.in +++ b/fb.in @@ -20,7 +20,9 @@ TAR= COMPRESS=0 TAREXT=".tar" TAROPTS="" +DISPLAYHISTORY= PASTEBIN="http://paste.xinu.at" +FBHIST="$HOME/.fb-client.hist" WARNSIZE=10485760 USERAGENT="fb-client/$VERSION" CLIPBOARD="" @@ -91,6 +93,8 @@ do_upload() { URL=`tail -1 $TMPFILE`"$EXTENSION" echo $URL CLIPBOARD="$CLIPBOARD $URL" + touch "$FBHIST" + echo "$URL :: $basefilename :: `date +%s` :: `stat -c %s -- "$file"`" >> "$FBHIST" } read_stdin() { @@ -121,6 +125,7 @@ usage: [cat |] `basename "$0"` [switches] [options] [] -g download the IDs and output on stdout (use with care!) -h this help -v show the client version + -H display an upload history Options: -e extension for default highlighting (e.g. "diff") @@ -131,7 +136,7 @@ usage: [cat |] `basename "$0"` [switches] [options] [] ! } -while getopts "e:gdhtcCv" OPTION; do +while getopts "e:gdhHtcCv" OPTION; do case $OPTION in e) EXTENSION="$OPTARG";; g) GET=1;; @@ -147,6 +152,7 @@ while getopts "e:gdhtcCv" OPTION; do ;; t) TAR=1;; d) DELETE=1;; + H) DISPLAYHISTORY=1;; v) echo "$VERSION"; exit 0;; h|\?) help; exit 0;; esac @@ -179,6 +185,17 @@ if [ "$DELETE" ] || [ "$GET" ]; then fi fi done +elif [ "$DISPLAYHISTORY" ]; then + maxage=`echo 10*24*60*60 | bc` + minsize=`echo 10*1024| bc` + + now=`date +%s` + oldest_time=`echo "$now - $maxage" | bc` + + awk -F" :: " ' + ($4 < '$minsize' || $3 < '$oldest_time' ) { print $1" - "$2} + ' $FBHIST + elif [ $# -eq 0 ]; then if [ "$TAR" ]; then echo "Error: -t is not supported when operating on stdin" >&2 -- cgit v1.2.3-24-g4f1b From 33fe9846fd0eca0c452bd6966c7a270ad389dae1 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 9 Jul 2011 16:59:20 +0200 Subject: remove ids from the history when called with -d Signed-off-by: Florian Pritz --- fb.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'fb.in') diff --git a/fb.in b/fb.in index 05ac03e..d1f80bb 100644 --- a/fb.in +++ b/fb.in @@ -172,7 +172,12 @@ if [ "$DELETE" ] || [ "$GET" ]; then for i in "$@"; do i=$(id_from_arg "$i") if [ "$DELETE" ]; then - $LIBDIR/fb-helper d "$PASTEBIN/file/delete/$i" || EXITCODE=1 + if $LIBDIR/fb-helper d "$PASTEBIN/file/delete/$i"; then + sed -i "/$i/d" $FBHIST + else + EXITCODE=1 + fi + elif [ "$GET" ]; then if [ "$COMPRESS" = "1" ]; then require_executable zcat -- cgit v1.2.3-24-g4f1b From 3e356c9539396c96d5e0645a3af551cdb538f54c Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 17 Jul 2011 23:33:27 +0200 Subject: don't add error to the history If $URL is not a URL the upload failed for some reason, so it should not be added to the history. Signed-off-by: Florian Pritz --- fb.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'fb.in') diff --git a/fb.in b/fb.in index d1f80bb..133e3d7 100644 --- a/fb.in +++ b/fb.in @@ -92,9 +92,11 @@ do_upload() { sed '$d' $TMPFILE >&2 URL=`tail -1 $TMPFILE`"$EXTENSION" echo $URL - CLIPBOARD="$CLIPBOARD $URL" - touch "$FBHIST" - echo "$URL :: $basefilename :: `date +%s` :: `stat -c %s -- "$file"`" >> "$FBHIST" + if echo $URL | grep -qE "^https?://"; then + CLIPBOARD="$CLIPBOARD $URL" + touch "$FBHIST" + echo "$URL :: $basefilename :: `date +%s` :: `stat -c %s -- "$file"`" >> "$FBHIST" + fi } read_stdin() { -- cgit v1.2.3-24-g4f1b