nsxiv-rifle: delete, using upstream now

This commit is contained in:
yosh 2023-09-21 10:05:18 -04:00
parent 71bcf3ed5b
commit 73837d24cc
1 changed files with 0 additions and 41 deletions

View File

@ -1,41 +0,0 @@
#!/bin/sh
TMPDIR="${XDG_RUNTIME_DIR}"
tmp="$TMPDIR/nsxiv_rifle_$$"
is_img_extension() {
rg -i '\.(jpe?g|png|gif|svg|webp|tiff|heif|avif|ico|bmp|jxl)$'
}
listfiles() {
fd . -L -d 1 -t f "$1" |
is_img_extension | sort | tee "$tmp"
}
open_img() {
file="$1"; shift;
# only go through listfiles() if the file has a valid img extension
if echo "$file" | is_img_extension >/dev/null 2>&1; then
trap 'rm -f "$tmp"' EXIT
count="$(listfiles "${file%/*}" | rg -nF "$file")"
fi
if [ -n "$count" ]; then
nsxiv -i -n "${count%%:*}" "$@" -- < "$tmp"
else
# fallback incase file didn't have a valid extension, or we couldn't
# find it inside the list
nsxiv "$@" -- "$file"
fi
}
[ "$1" = '--' ] && shift
case "$1" in
"") echo "Usage: ${0##*/} PICTURES" >&2; exit 1 ;;
/*) open_img "$1" ;;
"~"/*) open_img "$HOME/${1#"~"/}" ;;
trash:///*)
trash_dir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash/files"
open_img "${trash_dir}$(uri2path "$1")" -N "nsxiv_trash"
;;
*) open_img "$PWD/$1" ;;
esac