Skip to content

Instantly share code, notes, and snippets.

Last active October 23, 2022 06:05
What would you like to do?
Basic CLI loading animation
#!/usr/bin/env bash
for i in {0..12}; do
if ! (($i % 4)); then
printf "\e[1K\rloading"
printf "."
sleep 1
done && printf "\e[2K\r"
Copy link

dideler commented Nov 18, 2015

The terminal escapes are the interesting part.

\033[1K or \e[1K will clear from the cursor position to the beginning of the line.
\033[2K or \e[2K will clear everything on the line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment