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(-) 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