Skip to main content
The 2024 Developer Survey results are live! See the results
Tweeted twitter.com/super_user/status/1304117474129072135
Source Link

How can I make OSX terminal tab names the same as .ssh/config host aliases

Setting up a .ssh/config is a great time saver. The host aliases with user defined names make it easier keep track servers and key files. However, the OSX terminal tab names are displaying what ever the server says its host name is, instead of the host alias from the .ssh/config file.

For this entry:

Host CustName01
    HostName ec2-20-12-130-143.compute-1.amazonaws.com
    IdentityFile ~/.ssh/remote.pem
    User root

The OSX terminal tab name shows this:

root@domU-11-21-35-24-33-9A:~

I tried to solve the problem by setting the tab name before connecting:

Host *
    PermitLocalCommand yes

Host CustName01
    LocalCommand printf "\e]1;CustName01\a"
    HostName ec2-20-12-130-143.compute-1.amazonaws.com
    IdentityFile ~/.ssh/remote.pem
    User root

It sets the tab name before connecting, but then shows this again after connecting:

root@domU-11-21-35-24-33-9A:~

How can I get my tab to automatically show the CustName01 alias I specified in the ssh config file? Manually setting the value in the inspect tab dialog isn't what I'm after.

Executing the command to set the tab name while connected to a remote server does nothing:

printf "\e]1;CustName01\a"