misc/scripts/t

12 lines
341 B
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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