tags:

views:

99

answers:

1

printf '\e[s' will save the attributes and position of the cursor, so that the script can reset them using printf '\e[u'. But I only want to save the attributes. In other words, I want to change the color of text, print some text, and then restore the color settings at the end of the script. If I use the [s and [u sequences, I will be resetting the position, which I do not want.

What's the easiest way to restore the color attributes to the cursor without restoring the position?

A: 
   ESC 7 (DECSC)   save state
   ESC 8 (DECRC)   restore most recently saved state

Didn't try it out though ...