Question Change terminal colors depending on type of connection.

birne

Reputable
May 19, 2015
377
4
4,965
Hello,

I use the TeraTerm at work, and i tend to have a lot of simultanious sessions/windows.
sometimes i lose sight over wich window is what and was wondering if it is possible to have the terminal show a different color depending if it is a SSH, Telnet or COM-port connection

I know this is possible in putty/superputty, but i like teraterm and dont want to change.

I there someone who maybe has done this before and can give me a hint to how it is done.

Thanks in advanced
birne
 

Ralston18

Titan
Moderator
No need to bump. It can take some time to get any responses.

With respect to any given window the logic would be:

1) Identify the connection being used (SSH, Telnet, COM port)
2)Select the color via some IF-THEN-ELSE logic based on the connection type
3) Modify the Window's background color to the desired color. (Background being just an arbitrary choice on my part.)

My first thought was Powershell.

If you apply the Get-Services command on your computer are you able to identify the specific Name/DisplayName with respect to SSH, Telnet, or a COM-port connection?

If found and running then that would be used as a conditional to set the desired window color.

However that quickly seemed to become cumbersome.

So I did some additional research and found the following links:

https://beebom.com/how-change-powershell-color-scheme-windows-10/

https://devblogs.microsoft.com/commandline/introducing-windows-terminal/

Windows Terminal may prove to be more fitting.

So if you open certain windows that you know in advance are going to be SSH, Telnet, or COM-port then just set the corresponding colors as you wish.

The problem is more difficult if any given window changes connectivity and must then change color accordingly.

Not at all knowledgeable about your skills and experience nor the full circumstances with respect to the environment and requirements.

It does appear to be a viable thing to do and there are options as well.
 

birne

Reputable
May 19, 2015
377
4
4,965
No need to bump. It can take some time to get any responses.
Yes, sorry got a bit impatient :p

Just FYI I only use my terminal to connect to the CLI of either Cisco or HP switches, no servers or other kind of devices.

Now, the logic you provided would also be my guess as to how it could be done, but i was thinking it would be possible to so while only configuring the config file of teraterm.

The problem is more difficult if any given window changes connectivity and must then change color accordingly.
I know it should be possible to do because when i open an connection to one of my switches with SSH vs. Telnet the symbol of the window changes. (that's how i got the idea in the first place)
SSH vs Telnet
I just have not figured out/found the option to do so in the file.

I rather not change terminal program as i like Teraterm and got used to it (i know, stupid reason, but.)

My skills and experiences are somewhat limited, and i would have to test it out on my private PC before doing ANY kind of scripting on the company computer.

Also i often jump in and out (open/terminate) of these sessions very frequently, so it is out of question to set the colors manually each time.

I thought about installing two seperate instances of teraterm with different config files, and then using one for each connection type, but i already see me getting confused because of using the wrong one accidentally.
But maybe it is possible to just have two different config files and then letting teraterm choose the right one based on the connection-type. (have to look in to this one.)
 

Ralston18

Titan
Moderator
Interesting.

Identifying or finding some consistent flag is the key. I.e., a particular process or service that runs and only runs with respect to the connection type being used.

Very likely something you will need to experiment with on your private PC (wise choice).

Do you have desk space for Extended monitors? SSH sessions/windows on one monitor, Telnet on the other....

Sort of leaves COM ports hanging. But the "geography" could be worked out to help keep track of what window is what.

In the meantime I did a bit of tinkering on my own. Powershell seems promising.

Try Powershell Get-Service and Start Service.

Then set up a desktop short cut to run the applicable service. And change background color or some other indicator to keep track of things.

Starter link:

https://docs.microsoft.com/en-us/po...ll.management/start-service?view=powershell-6

Actually there are quite a number of similar links online. However, you know best about your situation and requirements.

All you need is one functional script and you can clone as necessary. May be easier than expected.