mirror of
https://github.com/jarun/nnn.git
synced 2025-01-23 17:26:42 +00:00
Merge pull request #1217 from N-R-K/nuke
nuke: port sxiv-rifle performance improvement over
This commit is contained in:
commit
b56e488f1c
21
plugins/nuke
21
plugins/nuke
|
@ -259,27 +259,32 @@ handle_extension() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# sets the variable abs_target, this should be faster than calling printf
|
||||||
abspath() {
|
abspath() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
/*) printf "%s\n" "$1";;
|
/*) abs_target="$1";;
|
||||||
*) printf "%s\n" "$PWD/$1";;
|
*) abs_target="$PWD/$1";;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# storing the result to a tmp file is faster than calling listimages twice
|
||||||
listimages() {
|
listimages() {
|
||||||
find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex \
|
find -L "///${1%/*}" -maxdepth 1 -type f -print0 |
|
||||||
'.*\(jpe?g\|bmp\|webp\|ico\|svg\|png\|gif\)$' -print0 | sort -z
|
grep -izZE '\.(jpe?g|png|gif|webp|tiff|bmp|ico|svg)$' |
|
||||||
|
sort -z | tee "$tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
load_dir() {
|
load_dir() {
|
||||||
target="$(abspath "$2")"
|
abspath "$2"
|
||||||
count="$(listimages | grep -a -m 1 -ZznF "$target" | cut -d: -f1)"
|
tmp="${TMPDIR:-/tmp}/nuke_$$"
|
||||||
|
trap 'rm -f $tmp' EXIT
|
||||||
|
count="$(listimages "$abs_target" | grep -a -m 1 -ZznF "$abs_target" | cut -d: -f1)"
|
||||||
|
|
||||||
if [ -n "$count" ]; then
|
if [ -n "$count" ]; then
|
||||||
if [ "$GUI" -ne 0 ]; then
|
if [ "$GUI" -ne 0 ]; then
|
||||||
listimages | xargs -0 nohup "$1" -n "$count" --
|
xargs -0 nohup "$1" -n "$count" -- < "$tmp"
|
||||||
else
|
else
|
||||||
listimages | xargs -0 "$1" -n "$count" --
|
xargs -0 "$1" -n "$count" -- < "$tmp"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
shift
|
shift
|
||||||
|
|
Loading…
Reference in a new issue