#!/bin/sh
#
# tre - colored tree

# shellcheck disable=SC2249
case "$1" in
  [0-9])
    depth="$1"
    shift
    ;;
esac
if command -v tree >/dev/null 2>&1; then
  # exec tree --dirsfirst --du -h -C -F -L "${depth:-3}" -I .git "$@"
  exec tree -C -F -L "${depth:-3}" -I .git "$@"
else
  exec find -- . -maxdepth "${depth:-3}" -path '*/.git' -prune -o -path './*' 2>/dev/null \
    | sed -Ee '2,$s:[^/]*/:   :g; s:   ([^ ]+)$:|_ \1:'
fi
