Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnome-terminal : how to set tab title from command line

I don't think this is going to work easily but I thought I'd ask just in case somebody has a clever trick or script to share. I want to configure my tab title to be the current working directory on a remote host where I am logged in from a gnome terminal. Ideally I want my title to read host:dir but I cant think of a way to pass back the $CWD from the remote host to gnome terminal. I am thinking that the only way to do this would be to have a "controller" wrapper to gnome terminal that can read back the cwd and set the terminal title. Any clever ideas on how to accomplish this?

like image 572
LostInTheFrequencyDomain Avatar asked Oct 19 '22 14:10

LostInTheFrequencyDomain


1 Answers

Amazingly simple answer.

echo -ne "\033]0;SOME TITLE HERE\007"

Does the job. I am posting here in an effort to be helpful to others:

The following does what I wanted it to do:

function cd() { builtin cd $1; echo -ne "\033]0;`basename $PWD`\007"; }

This tells me where I am in the remote machine by setting the title on my tab.

like image 166
LostInTheFrequencyDomain Avatar answered Oct 22 '22 06:10

LostInTheFrequencyDomain