commit ce0ef7e0148db212f0badf0a511875beaf7c145f parent e7986949c7d510b324f495304e6ec8f0ea01c638 Author: Byron Torres <b@torresjrjr.com> Date: Mon, 5 Dec 2022 04:48:25 +0000 lf*: fix and improve Diffstat:
M | bin/lf | | | 16 | ++++++++++------ |
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/bin/lf b/bin/lf @@ -3,9 +3,10 @@ list() { ( env printf '\x1b[01;34;4m%s\x1b[0m\n' "$(pwd)" - ls -FAXC -w 76 --color --group-directories-first "$@" \ + ls -FAXC -w76 --color --group-directories-first "$@" \ | awk ' - /:$/ {printf "\x1b[01;34m" $0 "\x1b[0m\n"} + /^\.:$/ {exit} + /:$/ {printf "\x1b[01;34m" $0 "\x1b[0m\n"} /^.*[^:]$/ {printf " " $0 "\n"} ' ) \ @@ -13,17 +14,20 @@ list() { } [ "$#" -eq 0 ] && { - [ "$(env printf '%s\n' * | wc -l)" -gt 1 ] && list * || list . + [ "$(ls)" = '' ] && list || list . * exit } cwd=$(pwd) - while [ $# -gt 0 ] do - cd "$1" 2>&- || { echo "No directory '$1'" ; shift ; continue ;} + cd "$1" 2>&- || { + echo "No directory '$1'" + shift + continue + } - [ "$(env printf '%s\n' * | wc -l)" -gt 1 ] && list * || list . + [ "$(ls)" = '' ] && list || list . * cd "$cwd" shift