#!/bin/sh -e
#
# tl - [t]ree [l]ist
#
# list files recursively with [dirsfirst] including hidden files (-a)
# showing sizes of directories (--du) and files in [h]uman readable form
# with forced [C]olorization and pipe into less
#
# if first arg is a digit, it displaces the default depth of 3
# any other arguments (usually pathnames) are passed on to the tree command

# shellcheck disable=SC2249
case "$1" in
  [0-9])
    depth="$1"
    shift
    ;;
esac
tree --dirsfirst --du -h -C -L "${depth:-3}" -I .git -I node_modules "$@" \
  | ${PAGER:-less} -rF
