Skip to content

Instantly share code, notes, and snippets.

@eban
Last active January 1, 2016 08:59
Show Gist options
  • Save eban/8121851 to your computer and use it in GitHub Desktop.
Save eban/8121851 to your computer and use it in GitHub Desktop.
#!/bin/bash
STAR=$' \u2605'
FSLASH=$'\uFF0F'
BSLASH=$'\uFF3C'
ORNAMENTS=(0069 0020 0020 0020 0020 0020
0020 0020 0020 0020 0020 0020
0020 2E1B 2042 2E2E 0026 0040 FF61)
ORNAMENT_COLORS=(21 33 34 35 36 37)
HAT='^'
tree() {
h=$1
printf "\n%${h}s\e[33m${STAR}\n"
m=$((h * 2 - 1))
eval set {1..$h}
for l; do
o=$((l * 2 - 2))
s=$(((m - o) / 2 + 1))
printf "%${s}s\e[32m${FSLASH}"
for ((j=0; j < o; j++)); do
or=${ORNAMENTS[${#ORNAMENTS[@]}*$RANDOM/32767]}
oc=${ORNAMENT_COLORS[${#ORNAMENT_COLORS[@]}*$RANDOM/32767]}
printf "\e[${oc}m\u$or"
done
printf "\e[32m${BSLASH}\n"
done
h1=$((h - 1))
spaces=$(printf "%*s" $h1)
hats="\e[32m${spaces// /$HAT}"
printf " ${hats}| |${hats}"
if (($h > 10)); then
printf "\n $spaces| |$spaces"
fi
printf "\n\n"
}
tree 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment