summaryrefslogtreecommitdiffstats
path: root/fb.in
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2011-08-15 11:20:01 +0200
committerFlorian Pritz <bluewind@xinu.at>2011-08-15 11:20:01 +0200
commit008a6fc33c39abaad71ec8ad64132713ca1177b3 (patch)
treed48d436c26e9f7011cb64291b6fe3da25d9f2b60 /fb.in
parent374a536f4e2cc561b768a8be463e7194a41bb952 (diff)
parent3e356c9539396c96d5e0645a3af551cdb538f54c (diff)
Merge branch 'history'
Diffstat (limited to 'fb.in')
-rw-r--r--fb.in30
1 files changed, 27 insertions, 3 deletions
diff --git a/fb.in b/fb.in
index 3af3b16..133e3d7 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=""
@@ -90,7 +92,11 @@ do_upload() {
sed '$d' $TMPFILE >&2
URL=`tail -1 $TMPFILE`"$EXTENSION"
echo $URL
- CLIPBOARD="$CLIPBOARD $URL"
+ 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() {
@@ -121,6 +127,7 @@ usage: [cat |] `basename "$0"` [switches] [options] [<file(s)|ID(s)|folder(s)>]
-g <ID(s)> 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> extension for default highlighting (e.g. "diff")
@@ -131,7 +138,7 @@ usage: [cat |] `basename "$0"` [switches] [options] [<file(s)|ID(s)|folder(s)>]
!
}
-while getopts "e:gdhtcCv" OPTION; do
+while getopts "e:gdhHtcCv" OPTION; do
case $OPTION in
e) EXTENSION="$OPTARG";;
g) GET=1;;
@@ -147,6 +154,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
@@ -166,7 +174,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
@@ -179,6 +192,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