I am looking for a script that creates a rotation animation using character /
,-
, |
and \
.
If you continuously switch between these characters it should look like its rotating. How to make this?
I am looking for a script that creates a rotation animation using character /
,-
, |
and \
.
If you continuously switch between these characters it should look like its rotating. How to make this?
Use that script:
The
while
loop runs infinite. Thefor
loop runs trough each character of the string given in$chars
.echo
prints the character, with a carriage return\r
, but without linebreak-n
.-e
forces echo to interpret escape sequences such as\r
. There's a delay of 0.5 seconds between each change.Here's an example using
\b
, which tells the terminal emulator to move the cursor one column to the left, in order to keep overwriting the same character over and over.See BashFAQ 34 for more.
Since you don't explicitly ask for bash, a little plug for the fish shell, where this can be solved beautifully IMO:
In this case,
symbols
is an array variable, and the contents if it are rotated/shifted, because$symbols[2..-1]
are all entries but the first.