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="\u0069 \u0020 \u0020 \u0020 \u0020 \u0020
\u0020 \u0020 \u0020 \u0020 \u0020 \u0020
\u0020 \u2E1B \u2042 \u2E2E \u0026 \u0040 \uFF61"
ORNAMENT_COLORS="21 33 34 35 36 37"
HAT=$'\u005e'
tree() {
h=$1
printf "\n%*s\e[33m${STAR}\n" $h ""
m=$((h * 2 - 1))
for ((l=1; l <= h; l++)); do
o=$((l * 2 - 2))
s=$(((m - o) / 2 + 1))
printf "%*s\e[32m${FSLASH}" $s ""
for ((j=0; j < o; j++)); do
or=$(shuf -n1 -e $ORNAMENTS)
oc=$(shuf -n1 -e $ORNAMENT_COLORS)
printf "\e[${oc}m$or"
done
printf "\e[32m${BSLASH}\n"
done
h1=$((h - 1))
hat=$(printf "%*s" $h1)
hats="\e[32m${hat// /$HAT}"
printf " ${hats}| |${hats}"
if (($h > 10)); then
printf "\n %*s| |%*s" $h1 "" $h1 ""
fi
printf "\n\n"
}
tree 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment