.sh

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

lf (534B)


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