Skip to content

Instantly share code, notes, and snippets.

@christianparpart
Last active July 18, 2020 20:13
Show Gist options
  • Save christianparpart/43f0d75986cb4b804b66834161f7639d to your computer and use it in GitHub Desktop.
Save christianparpart/43f0d75986cb4b804b66834161f7639d to your computer and use it in GitHub Desktop.
Terminal based Application cheat sheet

Terminal based Application cheat sheet

Naming convention

  • ESC 0x1b - Introduces an escape sequence
  • CSI 0x1B [- Control sequence introducer
  • OSC 0x1B ] - Operating system command

Functions

VT sequence Description Example
CSI row ; col H Position the cursor CSI 1 ; 1 H
CSI color m Set graphics rendition CSI 41 m
CSI 2 J clear the whole screen
CSI 3 J clear scrollback buffer (history)

Graphics Rendtion Table

color code name
30 foreground black
31 foreground red
32 foreground green
33 foreground yellow
34 foreground blue
35 foreground magenta
36 foreground cyan
37 foreground white
40 background black
41 background red
42 background green
43 background yellow
44 background blue
45 background magenta
46 background cyan
47 background white

C/C++ example

#include <stdio.h>

int main()
{
    printf("\033[1;1H\033[2J\033[3J"); // will do merely the same like your /usr/bin/clear command
    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment