-
-
Save ochafik/aef806cc1b697ec034b540cdaa9fd3aa to your computer and use it in GitHub Desktop.
Unicode block art in Bash for animated progress indicators or sliders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export amplitudeChars=( " " ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ) | |
| axis() { | |
| local negSym="$1" | |
| local posSym="$2" | |
| local value="$3" | |
| local maxAmplitude="$4" | |
| local amplitudeChar=${amplitudeChars[$( printf "%d" $(( value * ${#amplitudeChars[@]} / maxAmplitude )) )]} | |
| local percent=$( printf "%03d" $(( value * 100 / maxAmplitude )) ) | |
| if (( $value < 0 )); then | |
| echo -n "$negSym $amplitudeChar" | |
| elif (( $value > 0 )); then | |
| echo -n "$negSym $amplitudeChar" | |
| else | |
| echo -n " " | |
| fi | |
| } | |
| axis ⬇︎ ⬆︎ 50 100 | |
| axis ⬅ ⮕ 50 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -eu | |
| export seq1=( ▖ ▘ ▝ ▗ ) | |
| export seq2=( ▌ ▞ ▀ ▚ ▐ ▞ ▄ ▚ ) | |
| export seq3=( ▜ ▟ ▙ ▛ ) | |
| export seq4=( ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▂ ) | |
| sym1() { | |
| echo -n "${seq1[$(( i % ${#seq1[@]} ))]}" | |
| } | |
| sym2() { | |
| echo -n "${seq2[$(( i % ${#seq2[@]} ))]}" | |
| } | |
| sym3() { | |
| echo -n "${seq3[$(( i % ${#seq3[@]} ))]}" | |
| } | |
| sym4() { | |
| echo -n "${seq4[$(( i % ${#seq4[@]} ))]}" | |
| } | |
| export i=0 | |
| while true ; do | |
| echo -ne \ | |
| "\b\b\b\b\b\b\b\b$( sym1 $i ) $( sym2 $i ) $( sym3 $i ) $( sym4 $i ) " | |
| sleep 0.2 | |
| export i=$(( i + 1 )) | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <window height="250" width="300" duration="1:00:00.00" bgcolor="yellow"> | |
| <time begin="0:00:00.00" end="0:00:05.00"/> | |
| <pre> | |
| | ↑▄ ↑▄ | | |
| | ←▄ ✛ ▄→ ←▄ ✛ ▄→ | | |
| | ↓▄ ↓▄ | | |
| </pre> | |
| <time begin="0:00:05.00" end="0:00:10.00"/> | |
| <pre> | |
| | ↑▄ | | |
| | ←▄ ✛ ✛ ▄→ | | |
| | ↓▄ | | |
| </pre> | |
| <time begin="0:00:10.00" end="0:00:15.00"/> | |
| <pre> | |
| | ↑▄ | | |
| | ✛ ✛ | | |
| | ↓▄ | | |
| </pre> | |
| <time begin="0:00:05.00"/>Hello | |
| </window> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <pre><code> | |
| ⬆︎▄ ⬆︎▄ | |
| ▄⬅ ⮕▄ ▄⬅ ⮕▄ | |
| ⬇︎▄ ⬇︎▄ | |
| </code></pre> | |
| <pre><code> | |
| ↑▄ ↑▄ ↑▄ | |
| ▄← ✛ →▄ ▄← ✛ →▄ ▄←✛→▄ | |
| ↓▄ ↓▄ ↓▄ | |
| </code></pre> | |
| <pre><code> | |
| ↑▄ | |
| ▄← ✛ ✛ →▄ | |
| ↓▄ | |
| </code></pre> | |
| <pre> | |
| ↑▄ ↑▄ | |
| ←▄ ✛ ▄→ ←▄ ✛ ▄→ | |
| ↓▄ ↓▄ | |
| </pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment