Cygwin TERM type and ssh-ing to Linux (quick note)

I have been playing with Docker recently from my Windows based laptop. This means a lot more ssh-ing around the place than normal. Using Cygwin has been a help for consistency (shell scripts work on both), but when I ssh in, the TERM variable is set to “cygwin” which the Linux instances I was using does not understand. I tried “vt100”, but its not very good emulation. Here is how I got it to work, based on notes from P Conrad’s Cygwin notes.

cygwin$ infocmp -I 1 cygwin > cygwin.src
cygwin$ scp cygwin.src
cyginw$ ssh
core@CoreOS$ tic -v cygwin.src
core@CoreOS$ vi


Basically it extracts the terminal definition from Cygwin under Windows, copies it over the the remote host, compiles it up, then points to the user’s local TERMINFO database.

Of course, the above is too much like hard work when spinning up new instances all the time, so I created a bash function to do it all from Cygwin. I put the following in my ~/.bashrc file.

PushCygwinTerm () {
    infocmp -I -1 cygwin | ssh $* "cat > /tmp/cygwin.src; tic /tmp/cygwin.src"

This way I can run the command from my cygwin bash prompt, supplying any ssh command line arguments I like, and it gets the new terminal type installed for me before I go and log in.

It would of course be nicer to get the cygwin terminal definition into more versions of Linux, but the above is the next best thing.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: