Search code examples
colorssshenvironment-variableszshxterm

export TERM before ssh'ing


I'm using TERM='xterm-256color' on my laptop but have to use TERM='xterm' on a remote server where xterm-256color is not available and breaks down a few things.

So far I can do export TERM='xterm'; ssh -X 123.45.678.90, which works fine. But putting the previous line in an (zsh) alias (alias sshx="export TERM='xterm'; ssh -X 123.45.678.90") doesn't seem to work. E.g., if I insert a echo $TERM between the export and the ssh, doing everything in the command line echoes xterm, but the alias gives xterm-256color.

And of course, optimally, the TERM would be set back to its initial value after the ssh.

Is there a way to achieve this?

Thanks.


Solution

  • It is normally solved by

    alias sshx='TERM=xterm ssh -X 123.45.67.89'
    

    without exporting anything. In other case you will probably have to create a function.