Based on Mark B's answer, here is a simple demo:
spin () { chars="| / – \\" rotations=3 delay=0.1 for i in `seq 0 $rotations`; do for char in $chars; do echo -ne $char sleep $delay echo -ne '\b' done done }
Paste it into the terminal and type "spin".
Update: this version works in both bash and zsh.
spin () { char=( \| / – \\ ) charLastIndex=3 rotations=3 delay=0.1 for i in `seq 1 $rotations`; do for j in `seq 0 $charLastIndex`; do echo -n ${char[$j]} sleep $delay echo -ne '\b' done done }
Update: The liori version works in several shells.
spin () { rotations=3 delay=0.1 for i in `seq 0 $rotations`; do for char in '|' '/' '-' '\'; do
source share