Skip to content

Instantly share code, notes, and snippets.

@eban
Last active January 1, 2016 08:59

Revisions

  1. eban revised this gist Dec 25, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions xmas.sh
    Original file line number Diff line number Diff line change
    @@ -11,13 +11,13 @@ HAT='^'

    tree() {
    h=$1
    printf "\n%*s\e[33m${STAR}\n" $h ""
    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\e[32m${FSLASH}" $s ""
    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]}
  2. eban revised this gist Dec 25, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xmas.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ 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=$'\u005e'
    HAT='^'

    tree() {
    h=$1
  3. eban revised this gist Dec 25, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions xmas.sh
    Original file line number Diff line number Diff line change
    @@ -26,11 +26,11 @@ tree() {
    printf "\e[32m${BSLASH}\n"
    done
    h1=$((h - 1))
    hat=$(printf "%*s" $h1)
    hats="\e[32m${hat// /$HAT}"
    spaces=$(printf "%*s" $h1)
    hats="\e[32m${spaces// /$HAT}"
    printf " ${hats}| |${hats}"
    if (($h > 10)); then
    printf "\n %*s| |%*s" $h1 "" $h1 ""
    printf "\n $spaces| |$spaces"
    fi
    printf "\n\n"
    }
  4. eban revised this gist Dec 25, 2013. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions xmas.sh
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,9 @@
    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)
    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=$'\u005e'

    @@ -21,7 +21,7 @@ tree() {
    for ((j=0; j < o; j++)); do
    or=${ORNAMENTS[${#ORNAMENTS[@]}*$RANDOM/32767]}
    oc=${ORNAMENT_COLORS[${#ORNAMENT_COLORS[@]}*$RANDOM/32767]}
    printf "\e[${oc}m$or"
    printf "\e[${oc}m\u$or"
    done
    printf "\e[32m${BSLASH}\n"
    done
  5. eban revised this gist Dec 25, 2013. 1 changed file with 8 additions and 7 deletions.
    15 changes: 8 additions & 7 deletions xmas.sh
    Original file line number Diff line number Diff line change
    @@ -3,23 +3,24 @@
    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"
    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
    eval set {1..$h}
    for 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)
    or=${ORNAMENTS[${#ORNAMENTS[@]}*$RANDOM/32767]}
    oc=${ORNAMENT_COLORS[${#ORNAMENT_COLORS[@]}*$RANDOM/32767]}
    printf "\e[${oc}m$or"
    done
    printf "\e[32m${BSLASH}\n"
  6. eban created this gist Dec 25, 2013.
    37 changes: 37 additions & 0 deletions xmas.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    #!/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