ANSI Terminal Codes

June 29, 2026 ยท View on GitHub

Useful Terminal Escape sequences that I use in Bash scripts (can be used in any programming language really):

You might see functions like this in my DevOps-Bash-tools repo:

clear_current_line(){
    printf "\r\033[K"
}

clear_previous_line(){
    printf "\033[1A\033[2K\r"
}

and think what the hell are those codes.

You're not alone, it looks like magic until you have a cheet sheet for it.

TODO - make a cheet sheet for it below.