Custom terminal tab title and ssh on mac

In case you are using ssh private keys to connect to remote Linux servers on cloud, it is better to automation connection to various machines using bash script. I often connect to EC2 machines from my local macbook. Here is a sample script (you can save it as you can use to connect to a remote linux machine:

ssh -i /somepath/private_key.pem $1

Now to connect to, you can use the following command:


When you open multiple tabs and connect to various machine, the following bash code can be used in script:

printf "\e]1;`echo $* | sed -Ee 's/^.+\@//'`\a"
TERM=vt100 ssh -i /somepath/private_key.pem $*
printf "\e]1;bash\a"

You can customize it as per your need. Note that the code to set the tab title uses escape and bell char as shown below:

$ printf "\e]1;SOME_VALUE\a"
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments