"Reset" colors of terminal after ssh exit/logout
Solution 1:
Better:tput sgr0
is normally the equivalent of echo -en "\e[0m"
The difference is that using tput will adapt if the terminal type is other than ANSI - and it has been set up properly.
man 5 terminfo
for more codes to use.
In there you will find 'reset' so tput reset
should work.
$ echo -e "\e[7m TEST \e[0m" TEST $ echo -e "$(tput rev) TEST $(tput sgr0)" TEST $
(The TEST prints should have swapped background/foreground colors, cannot be shown here - only "emulated")
Found another option for this, a less geeky way:
the util-linux (on ubuntu) package contains setterm
(shell utility).
type setterm --help
and you'll find the available options.
The ACTUAL output of
tput sgr0
$ tput sgr0 | od -t x1z
0000000 1b 28 42 1b 5b 6d >.(B.[m<
0000006
... depends on how your terminal is set up, e.g.
$ set | grep TERM
TERM=xterm-256color
for the above.
$ infocmp ansi Reconstructed via infocmp from file: /lib/terminfo/a/ansi ansi|ansi/pc-term compatible with color, am, mc5i, mir, msgr, colors#8, cols#80, it#8, lines#24, ncv#3, pairs#64, acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J, cr=^M, cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, home=\E[H, hpa=\E[%i%p1%dG, ht=\E[I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=^J, indn=\E[%p1%dS, invis=\E[8m, kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, kich1=\E[L, mc4=\E[4i, mc5=\E[5i, nel=\r\E[S, op=\E[39;49m, rep=%p1%c\E[%p2%{1}%-%db, rev=\E[7m, rin=\E[%p1%dT, rmacs=\E[10m, rmpch=\E[10m, rmso=\E[m, rmul=\E[m, s0ds=\E(B, s1ds=\E)B, s2ds=\E*B, s3ds=\E+B, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, sgr0=\E[0;10m, smacs=\E[11m, smpch=\E[11m, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?%[;0123456789]c, u9=\E[c, vpa=\E[%i%p1%dd,
SEE ALSO (man pages):
tic(1) infocmp(1), captoinfo(1), infotocap(1), toe(1),
ncurses(3NCURSES), term(5). terminfo(5).
Explore more, begin here maybe https://en.wikipedia.org/wiki/Terminfo
Programmer's guide to ncurses - google books
note: ncurses provides interfaces for termcap, terminfo and of course curses.
Solution 2:
I believe you are looking for "reset" console command
Solution 3:
You might find using this in the remote .bash_logout more appropiate:
tput init
It might be good to have this on every .bash_logout as a general good practice (and perhaps even on ~/.profile)