Last active
September 10, 2025 09:43
-
-
Save dideler/b0a0ef8b95e683752883 to your computer and use it in GitHub Desktop.
Basic CLI loading animation
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
| #!/usr/bin/env bash | |
| for i in {0..12}; do | |
| if ! (($i % 4)); then | |
| printf "\e[1K\rloading" | |
| else | |
| printf "." | |
| fi | |
| sleep 1 | |
| done && printf "\e[2K\r" |
Author
you don't put $i in (( )). Just i is enough.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The terminal escapes are the interesting part.
\033[1Kor\e[1Kwill clear from the cursor position to the beginning of the line.\033[2Kor\e[2Kwill clear everything on the line.