Allow the TERM env variable to be overwritten by .ssh/config

Carson Gaspar carson at taltos.org
Tue Sep 23 09:22:26 EST 2014


On 9/22/2014 3:33 PM, Palmer Dabbelt wrote:
> This is pretty much the same request as an old mailing list thread
>
> http://marc.info/?l=openssh-unix-dev&m=134073696320230&w=2
[*snip*]
> The solutions proposed in that post don't work well for me because I
> like having a shared .bashrc and don't want to go making it super long
> just to have a big list of hosts that don't support "*-256color".

I don't like your patch as-is. If ssh needs something like this, it 
should be generic to any env var, not TERM specific. And then one could 
argue that a shell wrapper function could do the same thing (but 
wouldn't have identical destination parsing rules and would need config 
to live elsewhere, so there is some value in having such functionality 
in ssh itself).

Put something like this in your shell startup on the destination hosts 
to avoid maintaining a host list anywhere or patching ssh:

# Optionally wrap in "if test -t 1" to only bother on a TTY
local TRYTERMLIST=''
case "$TERM" in
   'rxvt-unicode-256color')
     TRYTERMLIST='rxvt-unicode-256color rxvt-256color xterm'
     ;;
esac
if test -n "$TRYTERMLIST" && test -x "$(type -P infocmp)"; then
   local T
   for T in $TRYTERMLIST; do
     if infocmp "$T" >/dev/null 2>&1; then
       export TERM="$T"
       break
     fi
   done
fi

Or, given that you appear to have a shared/dist'd home directory, just 
copy the correct terminfo file(s) into your home dir and set TERMINFO.

-- 
Carson



More information about the openssh-unix-dev mailing list