.sh

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

commit 01220f1f59722c2c068ce560d1a314580ff47fa4
parent 174da84c653716ce6e47891408ba43aa47deda80
Author: Byron Torres <b@torresjrjr.com>
Date:   Sat, 14 Aug 2021 17:59:19 +0100

lf*: Make printf and sed portable on Alpine

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

diff --git a/bin/lf b/bin/lf @@ -1,20 +1,20 @@ #!/bin/sh -eu list() { + esc=$'\x1b' ( - /usr/bin/printf '\x1b[01;34;4m%s\x1b[0m\n' "$(pwd)" + env 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 - ' + | sed -E \ + -e '/:$/,$s/^.*[^:]$/ \0/' \ + -e "s/^(.*):\$/${esc}[01;34m\1${esc}[0m:/" \ + -e '/^$/d' ) \ | more -f } [ "$#" -eq 0 ] && { - [ "$(printf '%s\n' * | wc -l)" -gt 1 ] && list * || list . + [ "$(env printf '%s\n' * | wc -l)" -gt 1 ] && list * || list . exit } @@ -24,7 +24,7 @@ while [ $# -gt 0 ] do cd "$1" 2>&- || { echo "No directory '$1'" ; shift ; continue ;} - [ "$(printf '%s\n' * | wc -l)" -gt 1 ] && list * || list . + [ "$(env printf '%s\n' * | wc -l)" -gt 1 ] && list * || list . cd "$cwd" shift