If I connect to one of my Pi using ssh
ssh [email protected]
This sets the macOS terminal tab title to "pi@MilliwaysPi4"
If I connect to one of my Macs using ssh
ssh [email protected]
The macOS terminal tab title remains at its default.
I can then manually set using the following:-
echo -en "\033]1; $(hostname) \007"
This sets the macOS terminal tab title to "Zaphod.local"
Is there any way to get macOS to automatically set the title?
Is there a ssh setting which would facilitate this behaviour?
I have tried many options;
Including echo -en "\033]1; $(hostname) \007"
after ssh
does not work, as any subsequent commands do not run on the host.
Including echo -en "\033]1; $(hostname) \007"
before ssh
sets the Title to the host on the host.
I could hard code the Title into a script before ssh
which does work, but often I use IP Address rather than a HOSTNAME so this is not generic.
Apparently something happens when sshing to Linux which sets the title, but not when sshing to macOS. Ideally I would like to discover what this is.
The Linux .bashrc contains
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
although frankly this is inscrutable.
echo
goes to Terminal so it doesn't matter on which host it runs. But check the shell init files on your Pi, whatever is done there to set the title will also work on your Mac.~/.bash_profile
containsexport PS1="\h:\[\033[0;30;33m\]\w\[\e[0m\]$ "
(which affects the prompt) but I am at a loss to find anything which would set title (but will continue looking)echo -en "\033]1; $(hostname) \007"
once logged in, does the title change?