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
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.
Perhaps this is too simple, but if you're concerned about your user-environment (and assuming everyone has their own account, and there's no crazy account-sharing going on where a bunch of people use the same username+password combo)...
Why not just add something into your own shell's environment file?
Korn (/bin/ksh) Shell (~/.kshrc)
Bourne Again (/bin/bash) Shell (~/.bashrc ~/.bash_profile)
(The above code should work without a problem)
Regular Bourne (/bin/sh) Shell (~/.profile)
(The above code, but /bin/sh doesn't do variable-splitting, so TTY_DEV will have to get more creative.)