.sh

Multi-shell dotfiles manager
git clone https://git.torresjrjr.com/.sh.git
Log | Files | Refs | README | LICENSE

commit 9bdac600926cd3809b409db889866c04a4066499
parent 0d2e0004f17f986341ce8625bfdc950f1903ab2d
Author: Byron Torres <b@torresjrjr>
Date:   Wed, 28 Jul 2021 02:06:52 +0100

Make lf* POSIX and not indent files in cwd

Diffstat:
Mbin/lf | 31+++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/bin/lf b/bin/lf @@ -2,10 +2,10 @@ list() { ( - printf '\x1b[01;34;4m%s\x1b[0m\n' "$(pwd)" + /bin/printf '\x1b[01;34;4m%s\x1b[0m\n' "$(pwd)" ls -FAXC -w 76 --color --group-directories-first "$@" \ | sed ' - s/^.*[^:]$/ \0/ + /:$/,$ s/^.*[^:]$/ \0/ s/^\(.*\):$/\x1b[01;34m\1\x1b[0m:/ /^$/d ' @@ -13,20 +13,19 @@ list() { | more -f } -main() { - [ "$#" -gt 0 ] && dirs="$@" || dirs=. - for dir in "${dirs}" - do - pushd "${dir}" 2>&- >/dev/null || { - echo "No directory '${dir}'"; continue ; - } +[ "$#" -eq 0 ] && { + [ "$(printf '%s\n' * | wc -l)" -gt 1 ] && list * || list . + exit +} - subs=$(find -maxdepth 1 -regex './[^.].*') - n=$(echo "${subs}" | wc -l) - [ "$n" = 1 ] && list . || list * +cwd=$(pwd) - popd >/dev/null - done -} +while [ $# -gt 0 ] +do + cd "$1" 2>&- || { echo "No directory '$1'" ; shift ; continue ;} + + [ "$(printf '%s\n' * | wc -l)" -gt 1 ] && list * || list . -main "$@" + cd "$cwd" + shift +done