bin: handle inspection of large directories without hang

This commit is contained in:
xeruf 2022-04-10 11:37:26 +02:00
parent 38c2f48a55
commit e9d7ad7305
2 changed files with 14 additions and 5 deletions

View File

@ -38,8 +38,14 @@ cd() {
test -n "$dir" && cd "$dir"
else
builtin cd "$@" &&
command ls --literal --file-type --color=always --format=vertical -U -w $COLUMNS |
#pr -4 -l1 -W $COLUMNS -S" " |
# we have to use two ls commands here, since:
# - a single ls command hangs on multi-column formats when combined with color
# - column malaligns output with ANSI escape sequences (view with LESS="" less)
# column --fillrows --output-width $(expr $COLUMNS + 20)
# pr -4 -l1 -W $COLUMNS -S" "
command ls --sort=none --quote-name |
head -12 |
xargs ls --sort=time --format=vertical --directory --literal --file-type --color=always --width $COLUMNS |
head -3
code=$? && test $code -eq 141 || return $code
fi

View File

@ -64,8 +64,8 @@ for arg; do
(*\ application/*document*)
# https://ask.libreoffice.org/t/convert-to-command-line-parameter/840/4
echo Converting "$arg"
soffice --headless --convert-to jpg --outdir "$prefix" "$arg" >/dev/null 2>&1
timg+=("${tmpfile%.*}.jpg")
soffice --headless --convert-to png --outdir "$prefix" "$arg" >/dev/null
timg+=("${tmpfile%.*}.png")
continue;;
(*/x-xcf*)
echo Converting "$arg"
@ -169,5 +169,8 @@ fi
if test "$ls" -o $# -eq 0; then
checkperm .
$elevate ls -l $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --group-directories-first --file-type --dereference-command-line --all "${ls[@]:-.}" | less -RF
# Alternative: find -exec ls -dl {} +
{ timeout .1s $elevate ls -l $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --group-directories-first --file-type --dereference-command-line-symlink-to-dir --all "${ls[@]:-.}" ||
$elevate ls $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --dereference-command-line --all --sort=none "${ls[@]:-.}"
} | less -RF
fi