.sh

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

commit b2ba579af20f9320acaa5c1bddcaefd391ffbe7b
parent c9e485c7aee49f3efc8f36247f7a722d47d424f2
Author: Byron Torres <b@torresjrjr.com>
Date:   Wed, 14 Jul 2021 23:32:45 +0100

Replace lf() with bin/lf*

Diffstat:
Abin/lf | 32++++++++++++++++++++++++++++++++
Msh/.rc.sh | 21---------------------
2 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/bin/lf b/bin/lf @@ -0,0 +1,32 @@ +#!/bin/sh -eu + +list() { + ( + printf '\x1b[01;34;4m%s\x1b[0m\n' "$(pwd)" + ls -FAXC -w 76 --color --group-directories-first "$@" \ + | sed ' + s/^.*[^:]$/ \0/ + s/^\(.*\):$/\x1b[01;34m\1\x1b[0m:/ + /^$/d + ' + ) \ + | more -f +} + +main() { + [ "$#" -gt 0 ] && dirs="$@" || dirs=. + for dir in ${dirs} + do + pushd "${dir}" 2>&- >/dev/null || { + echo "No directory '${dir}'"; continue ; + } + + subs=$(find -maxdepth 1 -regex './[^.].*') + n=$(echo "${subs}" | wc -l) + [ "$n" = 1 ] && list . || list * + + popd >/dev/null + done +} + +main "$@" diff --git a/sh/.rc.sh b/sh/.rc.sh @@ -51,27 +51,6 @@ info() { } } -lf() { - [ -n "$1" ] && { - [ -d "$1" ] && pushd "$1" >/dev/null || { - echo "No directory '$1'"; return 1 - } - } - - ( - printf '\x1b[01;34;4m%s\x1b[0m\n' "$(pwd)" - la -w 76 --color * \ - | sed ' - s/^.*[^:]$/ \0/ - s/^\(.*\):$/\x1b[01;34m\1\x1b[0m:/ - /^$/d - ' - ) \ - | more -f - - [ -n "$1" ] && popd >/dev/null -} - gitf() { echo ">>>" git fetch