Fix terminal title after SSH remote logging to another machine

now I am making use of an one - line perl code to transform titles of my terminal bars,


yet every single time after I ssh to an additional remote equipment, the title will certainly be changed by the host (through which I'm not specifically troubled). Yet after I exit from the link, the changed title continues to be. Exists a means to repair this? basically I desire a dealt with title for my terminals when running in your area.

I largely make use of xfce terminal and also terminator under either CentOS or Debian, Thanks


Another nuance is that, instead having all terminals the very same name, I would certainly favor to have the liberty to modify their titles on - the - fly yet just restricted SSH session from changing what I modified.

2022-06-07 14:39:32
Source Share
Answers: 3

ADD these lines to ~/. bashrc

# If this is an xterm set the title to [email protected]:dir
case "$TERM" in
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\[email protected]\h: \w\a\]$PS1"


functions well with debian based linuxes

2022-06-08 03:21:03

Configure your neighborhood shell dotfile (as an example $PROMPT_COMMAND in ~/.bashrc) to set the terminal title suitably, making use of the very same device.

As an example:

export PROMPT_COMMAND="printf '\e]0;bash\7\n'"
2022-06-07 15:10:50

I do not find out about window titles, yet I have actually been attempting to have my system do something on ending a ssh session bdsh in fact, after ending a ssh session. Basically: it does not function like that. Primarily you have 3 selections:

  1. Write a wrapper around ssh, i.e., an executable shell manuscript called ssh that takes priority over /usr/bin/ssh in your $PATH which has the line exec /usr/bin/ssh [email protected] someplace in its center. This allows you to have your shell do some things prior to and also after the reliable ssh binary is run, while maintaining th eoverhead to a minimum.

  2. Write a spot versus the SSH resources of your selection to give you a cleaning hook that implements a shell command passed using commandline or some config - setup. That is what we desire.

  3. Have PROMPT_COMMAND review the result of history. Primarily an extra common and also extra hideous strategy to 1.

2022-06-07 15:08:28