From cab633dd5002a157a718114b5db6177fc52eac97 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Fri, 5 Mar 2021 17:26:17 +0100 Subject: [PATCH] scripts/t: a fancier tree --- scripts/t | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 scripts/t diff --git a/scripts/t b/scripts/t new file mode 100755 index 0000000..6e0a990 --- /dev/null +++ b/scripts/t @@ -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