.sh

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

lf (584B)


      1 #!/bin/sh -eu
      2 
      3 esc=$(printf '\x1b')
      4 
      5 list() {
      6 	(
      7 		env printf '\x1b[01;34;4m%s\x1b[0m\n' "$(pwd)"
      8 		ls -FAXC -w76 --color --group-directories-first "$@" \
      9 		| awk '
     10 			/^\.:$/    {exit}
     11 			/:$/       {printf "\x1b[01;34m" $0 "\x1b[0m\n"}
     12 			/^.*[^:]$/ {printf "    " $0 "\n"}
     13 		'
     14 	) \
     15 	| sed -E "s|\.([^. ]*)( *)|.$esc[1m\1$esc[0m\2|g" \
     16 	| more -ef
     17 }
     18 
     19 [ "$#" -eq 0 ] && {
     20 	[ "$(ls)" = '' ] && list || list . *
     21 	exit
     22 }
     23 
     24 cwd=$(pwd)
     25 while [ $# -gt 0 ]
     26 do
     27 	cd "$1" 2>&- || {
     28 		echo "No directory '$1'"
     29 		shift
     30 		continue
     31 	}
     32 
     33 	[ "$(ls)" = '' ] && list || list . *
     34 
     35 	cd "$cwd"
     36 	shift
     37 done