Add support for hidden images if initial file is hidden

If the initial image is hidden, the script uses ls -a to include other hidden files; otherwise, it uses the default behaviour.
This commit is contained in:
Peter MacKenzie-Basaraba 2025-03-25 12:41:43 -06:00 committed by GitHub
parent fdfd23a82c
commit 7f2211a921
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,4 +9,11 @@
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
base="$(basename "$1")"
ls "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }'
if [[ "$base" == .* ]]; then
ls_opt="ls -a"
else
ls_opt="ls"
fi
$ls_opt "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }'