From e9d7ad730511e22690affb2d6217e654028a3bd9 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sun, 10 Apr 2022 11:37:26 +0200 Subject: [PATCH] bin: handle inspection of large directories without hang --- .config/shell/browse | 10 ++++++++-- .local/bin/scripts/b | 9 ++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.config/shell/browse b/.config/shell/browse index ae0dede..0c3d384 100644 --- a/.config/shell/browse +++ b/.config/shell/browse @@ -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 diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index 3ad69d7..8a5fb8a 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -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