I tried many things but tmux seems to be very stubborn on this one.

When I start a tmux session in bash it shows


in my status bar. Then when I ssh to a server it gives me


When I then exit the ssh session, the status bar does not revert to the previous

0:bash*, it just keeps the 0:user@server:~*

which is annoying to me. I checked the man page, searched the internets, but hope the hive mind can assist me here.

This is all I have in my .tmux.conf,

set -g mouse on
set -g default-terminal "screen-256color"

tmux -V outputs tmux 2.6

  • [1] Check /etc/tmux.conf [2] Try set-option status off then set-option status on to check [3] Check PROMPT_COMMAND on local machine & on SSH machine
    – Prem
    Commented Sep 13, 2022 at 12:34
  • I don't have a /etc/tmux.conf and when I try [2] and then start a tmux session it hangs with a warning: /home/me/.tmux.conf:14: no current session Commented Sep 13, 2022 at 13:28
  • Here, [2] was supposed to be "executed" in the current session ( not in a new session ) via "CTRL-B COLON set-option status off" then "CTRL-B COLON set-option status on" ! Ok, Did you check [3] ? Your Post gives 2 lines on tmux conf, but the error message Points to line 14 ! Are there more lines in your tmux conf ?
    – Prem
    Commented Sep 13, 2022 at 14:20
  • Ok, thanks for the feedback, will try it later (executing as command). There are more lines in my .tmux.conf, but all but the 2 I mentioned are commented out. Commented Sep 13, 2022 at 16:24
  • resetting status option doesnt change it back. PROMPT_COMMAND on ssh machine indeed sets the user and server in tmux's status bar, but when exiting from remote machine, the status bar stil does not reset. I searched, but can't find how to set it Commented Sep 15, 2022 at 8:56

1 Answer 1


Problem : TMUX changes Status Bar when connecting to SSH Server & DOES NOT change it back when exiting that SSH Server.

Solution : PROMPT_COMMAND is the Environment Variable which gives the value to be shown in TMUX Status Bar. That is missing on local machine. Put that Exact Setting (taken from SSH Server) in local bash rc file. Exit TMUX & start new TMUX Session.

In SSH Server bash rc file, you may see something like this :

PROMPT_COMMAND="echo -ne \"\033]0;$USER (on $HOSTNAME)\007\""

Put the Exact Setting in local machine.

New TMUX window or new TMUX Session will work correctly now.

In case that is not helping, then BASH is setting the window title but TMUX is not using it.
Then we have to make TMUX use the title via this :
CTRL-B COLON set-options -gw windows-status-format "#I:#W#F"
CTRL-B COLON set-options -gw windows-status-current-format "#I:#W#F"
CTRL-B COLON set-options -gw automatic-rename on

Now, BASH will be setting the window title & TMUX will be using that.
When SSH changes the window title & then later, SSH Exits, then TMUX will Correctly update the window title.

  • It is not missing on local machine. I have git-aware prompt on my local machine, and indeed for NEW tmux windows it shows the correct information on the status bar, but after connecting to SSH server it wont change back after exiting. In my current workflow I now exit that tmux window and start a fresh one, because it is really annoying that it persists the ssh machine's name when the connection is gone. Commented Sep 15, 2022 at 9:20
  • Maybe it has to do with GNOME Terminal 3.28.2? Commented Sep 15, 2022 at 9:29
  • I have updated my Post , incorporating it with your latest comments ; I think that will work !
    – Prem
    Commented Sep 15, 2022 at 12:12
  • 1
    Some Positive News : I am seeing the Exact Same Issue with "automatic-rename off" & Issue goes away with "automatic-rename on" : I think that Missing Setting will Solve the Issue !! @SjorsBranderhorst
    – Prem
    Commented Sep 15, 2022 at 15:26
  • 1
    Where you have $I, should that be #I ? Commented Mar 14 at 5:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .