Skip to content

Instantly share code, notes, and snippets.

@jigpu
Created January 28, 2018 17:38
Show Gist options
  • Select an option

  • Save jigpu/a93ee564622beecce444c753fcfe1b78 to your computer and use it in GitHub Desktop.

Select an option

Save jigpu/a93ee564622beecce444c753fcfe1b78 to your computer and use it in GitHub Desktop.
Simple script to spin the terminal cursor in various ways.
#!/bin/sh
# Note:
# https://en.wikipedia.org/wiki/ANSI_escape_code
# https://www.fileformat.info/info/unicode/block/block_elements/list.htm
function spin {
CHRS=$1
DELAY=$2
X=0;
trap "printf '\033[?25h'; exit" 2
printf '\033[?25l'
while true; do
X=$(((X+1)%${#CHRS}))
#printf '%s\033[1D' "${CHRS:$X:1}"
printf '%s\b' "${CHRS:$X:1}"
sleep $DELAY
done
}
ASCII='-\|/'
BLOCKWISE='▖▘▝▗'
FADE=' ░▒▓█▓▒░'
FISHTAIL=' ▖▌▙█▜▐▝'
GROWXSHRINKX=' ▏▎▍▌▋▊▉█▉▊▋▌▍▎▏'
GROWXSHRINKY=' ▏▎▍▌▋▊▉█▇▆▅▄▃▂▁'
GROWYSHRINKY=' ▁▂▃▄▅▆▇█▇▆▅▄▃▂▁'
spin "$BLOCKWISE" 0.1333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment