From: W. Trevor King Date: Fri, 30 Mar 2012 01:40:52 +0000 (-0400) Subject: Add -l option to cache-file.sh, so you can hard-link instead of move files. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1c047565f87c392a76baff8cc6324ed3279c6a45;p=blog.git Add -l option to cache-file.sh, so you can hard-link instead of move files. --- diff --git a/posts/cache-file.mdwn b/posts/cache-file.mdwn index c2c1ecf..eae2d5e 100644 --- a/posts/cache-file.mdwn +++ b/posts/cache-file.mdwn @@ -2,13 +2,14 @@ pictures using [pqiv][]. If you place `cache-file.sh` in your path, and add - -1 "cache-file.sh saves" + -1 "cache-file.sh -l saves" -2 "cache-file.sh trash" -to `~/.pqivrc`, you can move the current picture to `.cache-saves/` or -`.cache-trash/` by pressing 1 or 2 respectively. The `.cache-*/` -directory is in the same directory as the image file, and will be -created if it doesn't exist. +to `~/.pqivrc`, you can hard link the current picture to +`.cache-saves/` or by pressing 1, or move the current picture to +`.cache-trash/` by pressing 2. The `.cache-*/` directory is in the +same directory as the image file, and will be created if it doesn't +exist. Not very complicated, but useful for quickly removing almost-duplicates, blurry pictures, etc. diff --git a/posts/cache-file/cache-file.sh b/posts/cache-file/cache-file.sh index 0f3f310..b412d72 100755 --- a/posts/cache-file/cache-file.sh +++ b/posts/cache-file/cache-file.sh @@ -2,7 +2,7 @@ # # Something along the lines of qiv's .qiv-save and .qiv-trash for pqiv. # -# Copyright (C) 2010 W. Trevor King +# Copyright (C) 2010-2012 W. Trevor King # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,9 +19,19 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # -# usage: cache-file.sh TAG FILE +# usage: cache-file.sh [-l] TAG FILE PREFIX=".cache-" + +if [ "$1" == '-l' ]; then + CMD='cp -l' + VERB='hard-linked' + shift +else + CMD='mv' + VERB='moved' +fi + TAG="$1" FILE="$2" @@ -45,6 +55,6 @@ if [ ! -d "$CACHE_DIR" ]; then mkdir "$CACHE_DIR" fi -mv "$FILE" "$CACHE_DIR" +$CMD "$FILE" "$CACHE_DIR" -echo "moved '$FILE' to '$CACHE_DIR'" +echo "$VERB '$FILE' to '$CACHE_DIR'"