Detect terminal type with tput

command-line-interfacesolaristerminfo

I would like to configure the terminal type by detecting it. For example when I am connecting to a Solaris box with PuTTY, the $TERM variable is set to vt100. I would like to negotiate this so, when the terminal emulator is PuTTY, to set $TERM to xterm.

I've noticed that at ^E PuTTY answers back with PuTTY. But I think that the best method is to use tput to try to detect the terminal emulator type. The problem is that I could not find any reference in the terminfo or tput manual how to do this.

Otherwise I will try with something based on:

unset remote_term;echo $'\cE';read -rt 1 -n5 remote_term ;echo remote_term=$remote_term

Best Answer

Any reason why you can't just set the connection options in PuTTY to negotiate the desired terminal type?

Under PuTTY configuration, Click Connection -> Data, and then set the "Terminal-type string" in the Terminal Details section to whatever terminal type you want. Mine is set to ansi but you can easily change that to xterm.

This is more elegant than intercepting the Ctrl-E answerback as it respects the user's intent for the terminal type.