Escapes
:bell
: makes the terminal make the error soundbackspace
: deletes the character behind the cursor, unless there are no characters behind the cursor. Newline does not count as a character.saveScreen
: saves all content on the current screenDISCLAIMER: it will only save the line which contains the command used to start the script, and any output that the program makes that is in view!
loadScreen
: loads the previous savenewline
: makes a new line and moves cursor to the start of the new lineformfeed
: form feed, or new pagecarraigeReturn
: printed after newline in raw or cbreak mode to make newline work properly in those modesesc
: starts an escape codedelete
: delete key, not sure what it does but it does do somethingTabs
: class that stores tabsvertical
: a wierd tab that probably has no usehorizontal
: a normal tab
Cursor
: cursor related escape codesmakeInvisible
: hide the cursormakeVisible
: show the cursorhome
: move the cursor to home ((1,<insert first row>)
)moveEscape
: generates a escape that moves the cursor to row,column.syntax:
moveEscape(row,column)
, whererow
andcolumn
are int values or string representations of int values.
DISCLAIMER: the coordinates start at 1, not 0, and the row that contains the command prompt used to run the script is usually reserved, and you are unable to move there untill the command prompt is pushed up with newlines!save
: saves the current cursor positionload
: loads the last saved cursor positionupEscape
: generates a escape that moves the cursor upn
linessyntax:
upEscape(n)
, wheren
is a int value or a string representation of a int valuedownEscape
: generates a escape that moves the cursor downn
linessyntax:
downEscape(n)
, wheren
is a int value or a string representation of a int valueleftEscape
: generates a escape that moves the cursor leftn
linessyntax:
leftEscape(n)
, wheren
is a int value or a string representation of a int valuerightEscape
: generates a escape that moves the cursor rightn
linessyntax:
rightEscape(n)
, wheren
is a int value or a string representation of a int value
Erase
: escapes related to erasing the screenscreen
: clears the screenscrollbackScreen
: clears the screen by printing <terminal height> newlines. Does not work properly when cursor is not at homescrollback
: clears scrollbackeraseLine
,line
: they both clear the current line. If you figure out the difference between them, please help me update this file.fromCursor
: escapes to clear from cursortoEndOfScreen
: erases everything from cursor to end of screentoStartOfScreen
: erases everything from cursor to start of screentoStartOfLine
: erases from the cursor to the start of the linetoEndOfLine
: erases from the cursor to the end of the line
Style
: escapes to change the style of textreset
: resets all stylebold
: makes all the text printed after printing this bolddim
: makes all the text printed after printing this dimitalic
: makes all the text printed after printing this italicunderline
: makes all the text printed after printing this underlinedblink
: makes all the text printed after printing this blinkinvert
: makes all the text printed after printing this have it's color inverted from the current colorinvisible
: makes all the text printed after printing this be invisiblestrikethrough
: makes all the text printed after printing this be struck through
Color8
: 8 basic ansi colors that are supported widelyForeground
: foreground color escape codesblack
: makes the foreground of all text printed after printing this blackred
: makes the foreground of all text printed after printing this redgreen
: makes the foreground of all text printed after printing this greenyellow
: makes the foreground of all text printed after printing this yellowblue
: makes the foreground of all text printed after printing this bluemagenta
: makes the foreground of all text printed after printing this magentacyan
: makes the foreground of all text printed after printing this cyanwhite
: makes the foreground of all text printed after printing this white
Background
: background color escape codesblack
: makes the background of all text printed after printing this blackred
: makes the background of all text printed after printing this redgreen
: makes the background of all text printed after printing this greenyellow
: makes the background of all text printed after printing this yellowblue
: makes the background of all text printed after printing this bluemagenta
: makes the background of all text printed after printing this magentacyan
: makes the background of all text printed after printing this cyanwhite
: makes the background of all text printed after printing this white
Color256
: 256 basic ansi colors that are supported widelyForeground
: foreground escapescolor
: function to make color escape codeSyntax:
color(n)
, wheren
is the ID of your color (IDs end at 256) -Background
:color
: function to make color escape codeSyntax:
color(n)
, wheren
is the ID of your color (IDs end at 256)
TrueColor
escapes for the full RGB range. some terminals dont supportForeground
: foreground escapescolor
: function to make color escape codeSyntax:
color(r,g,b)
, wherer
,g
, andb
are the rgb values of your color -Background
:color
: function to make color escape codeSyntax:
color(r,g,b)
, wherer
,g
, andb
are the rgb values of your color
newlinelessPrint
: function to print string without newlineSyntax:
newlinelessPrint(string)
, wherestring
is the string to be printed
- Install FUNC
- Run this:
PYPATH=$(python3 -c "import os;print(os.__file__.replace('os.py',''))")
curl https://raw.githubusercontent.com/lomnom/ESCAPES/main/ESCAPES.py > "$PYPATH"ESCAPES.py
- uninstall FUNC
- Run this:
PYPATH=$(python3 -c "import os;print(os.__file__.replace('os.py',''))")
rm "$PYPATH"ESCAPES.py
Disclaimers:
- Some escape codes do not work in certain terminals, such as strikethrough, which does not work in terminal.app
- If you called one of these thinking they were functions, and got
TypeError: 'str' object is not callable
, you tried to call an escape code, which is meant to be printed.
Also, a HUGE thank you to fnky, who made this gist, which is where i took almost all of these escape codes from