Skip to content

Instantly share code, notes, and snippets.

@HariSekhon
Created June 9, 2026 00:03
Show Gist options
  • Select an option

  • Save HariSekhon/1226b668f4a61ce3f3f98c3fe82f927b to your computer and use it in GitHub Desktop.

Select an option

Save HariSekhon/1226b668f4a61ce3f3f98c3fe82f927b to your computer and use it in GitHub Desktop.
ansi.md from HariSekhon/Knowledge-Base repo: https://github.com/HariSekhon/Knowledge-Base

ANSI Terminal Codes

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.

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