scripts/t: a fancier tree

This commit is contained in:
Michele Guerini Rocco 2021-03-05 17:26:17 +01:00
parent 883bfe5307
commit cab633dd50
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

11
scripts/t Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# compact version of tree
res=$(tree --dirsfirst --noreport -L 2 -C "$@" \
| awk '/^├|└/{l1=0} /^│/{l1+=1} {if (l1 <= 5){print $0} if(l1 == 6){print "│   ├── ..."}}' \
| sed 's/ / /g')
if test $(printf "%s\n" "$res" | wc -l) -gt $(tput lines)
then printf "%s\n" "$res" | less -RSicX
else printf "%s\n" "$res"
fi