I can set the tab name using ⌘ I or echo -en "\033]1; NAME \007"
What I would like to do is set this automatically when I ssh
into a remote system rather than the user@hostname
I normally get.
I have searched terminal & ssh documentation but not found any workable solution.
I can change tab name in a script but it is always overwritten by ssh
.
After connecting I can again set tab name, but I would like to automate this.
The supposed duplicate seems to be about setting AFTER ssh
exits; I want during ssh
and often have ~6 ssh sessions open.
I have tried export PROMPT_COMMAND="echo -ne '\033]0;NAME\007';$PROMPT_COMMAND"
before ssh
but this seems to have no effect and of course running after connect doesn't either.
There is nothing in my Linux .profile
which sets this.
NOTE the title is set to user@hostname even if I use ssh user@IPaddress
so this is almost certainly coming from the ssh server, but this does not seem to be documented.
Profiles/Window/Title is set to "Term" which is overwritten (with user@hostname ~
- the Linux prompt) when ssh
connects.
Profiles/Window/Tab is empty (although I have experimented with settings to no effect)
The only way I have found to change after connection in to use ⌘ I
then manually set the Tab title. If I could automate this it would be a viable solution.
PROMPT_COMMAND
on the server is empty (unless I set as suggested when it shows "true").
I tried
ssh -t -t -t hostname "echo -en \"\033]1; Pi3+ \007\"; exec /bin/bash --noprofile --norc"
as suggested by jaume, which DID successfully set Tab name.
Unfortunately none of my aliases etc work so this is not a workable solution, but maybe with further work it will. This also sets Terminal Window title to user@hostname ~
, but frankly I don't care what the Window says.
echo -en "\033]1; NAME \007"
, doesNAME
stick or does it get overwritten?ssh
session doesn't override the tab title, but the shell on the remote system (usually because the shell startup scripts set thePROMPT_COMMAND
environment variable). To prevent this from happening, you can forcessh
to run a session that selectively setsPROMPT_COMMAND
. Forbash
, can you try the following command (it should set the tab title to "IT WORKED", ):ssh -t -t -t hostname 'exec /bin/bash --noprofile --rcfile <(cat ~/.bashrc; echo "export PROMPT_COMMAND=\"true\""; echo "echo -ne \"\033]0;IT WORKED\007\"")'
(replacehostname
as necessary) and report back?