commit 2a3be788b00b8eb2602394efe8beeafba8ce8300
parent f3cb6e921d415f1089af84dae6352868ead87959
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 20 May 2020 14:52:34 +0200
Add optional filtering for listings
Diffstat:
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/.local/bin/upload b/.local/bin/upload
@@ -20,22 +20,23 @@ show_help() {
echo "The program prints the upload URL for each file to standard output"
echo
echo "OPTIONS are one or more of the following:"
- echo " -h, --help show this message"
- echo " -V, --version show version and license information"
- echo " -v, --verbose show verbose information (e.g. upload progress)"
- echo " -n, --notify also show diagnostic output with notify-send"
- echo " -c, --clip send upload url to clipboard"
- echo " -- do not consider any following arguments as options"
- echo " -b, --border if an image, add a 10% white border to FILES"
- echo " -r, --resize if an image, resize FILES to fit 800x800 pixels"
- echo " without changing its width-to-height ratio"
- echo " -s, --sharpen if an image, sharpen all FILES"
- echo " -p, --public operate on public file directory (/${pubdir})"
- echo " -o, --gopher return gopher URI instead of http"
- echo " -g, --get get previously uploaded FILES instead of uploading"
- echo " -l, --list list previously uploaded files"
- echo " -d, --delete delete previously uploaded FILES instead of uploading"
- echo " --get and --delete can be used together"
+ echo " -h, --help show this message"
+ echo " -V, --version show version and license information"
+ echo " -v, --verbose show verbose information (e.g. upload progress)"
+ echo " -n, --notify also show diagnostic output with notify-send"
+ echo " -c, --clip send upload url to clipboard"
+ echo " -- do not consider any following arguments as options"
+ echo " -b, --border if an image, add a 10% white border to FILES"
+ echo " -r, --resize if an image, resize FILES to fit 800x800 pixels"
+ echo " without changing its width-to-height ratio"
+ echo " -s, --sharpen if an image, sharpen all FILES"
+ echo " -p, --public operate on public file directory (/${pubdir})"
+ echo " -o, --gopher return gopher URI instead of http"
+ echo " -g, --get get previously uploaded FILES instead of uploading"
+ echo " -l, --list [QUERY] list previously uploaded files with optional QUERY"
+ echo " search string as filter"
+ echo " -d, --delete delete previously uploaded FILES instead of uploading"
+ echo " --get and --delete can be used together"
echo "the optional operations are performed in the order listed above."
echo "${0##*/} requires imagemagick and rsync to be installed on the system."
}
@@ -150,7 +151,11 @@ delete_file() {
}
list_uploads() {
- ssh "$user"@"$host" "ls -lah '${remotedir}/'"
+ if [ -z "$1" ]; then
+ ssh "$user"@"$host" "ls -lah '${remotedir}/'"
+ else
+ ssh "$user"@"$host" "ls -lah '${remotedir}/'" | grep "$1"
+ fi
}
die() {
@@ -211,7 +216,7 @@ while :; do
delete=1
;;
-l|--list)
- list_uploads
+ list_uploads "$2"
exit 0
;;
--) # end all options