While printing text for your tests or any other thing you sometimes want to make better output to make your tests look more elegant or whatever reason.
Using colors makes them quite cool but if you want to take it to the next level you can move cursor and rewrite over your text to make it look as an update.
This is more like a note to myself because I’ll be using it shortly for my sh2d
project that you can find here and for which I’ll write a post later.
Meaning of symbols:
<L>
Line<C>
Column<N>
a numberHere they are:
\033[<L>;<C>H
or \033[<L>;<C>f
. If you don’t change the cursor position again the shell prompt may erase other things you wrote earlier\033[2J
. This one is odd, test by yourself, you’ll understand…\033[<N>A
. It never erase before the first visible line\033[<N>B
. It never scroll down more than the number of visible lines\033[<N>C
. It never goes over to the next line\033[<N>D
. It never goes back to the previous line\033[s
\033[u
This is not an exhaustive list but it covers the main codes and it’s enough to work with.
To find more characters sequence you can check them here: ANSI escape code. Again it’s not a complete list ^^