Red Hat Bugzilla – Bug 166514
Terminal title not updated properly
Last modified: 2016-09-19 22:36:30 EDT
Description of problem:
When ssh'ing into a remote system, zsh will update the terminal title to
'username@host', but when I log out it does not get updated -- which can lead to
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. ssh into a remote system
The terminal title will still show 'username@host' for the system that you
previously sshed into.
The title should be updated to show the current username@host.
This issue seems to be resolved by putting the following in my .zshrc ( possibly
suitable for /etc/zshrc ? ):
print -Pn "\e]0;%n@%m: %~\a"
I'm far from a zsh expert, so there are probably better ways to approach this.
This does not happen automatically. You have configured something to set the
terminal title when you ssh in. From the zsh FAQ (/usr/share/doc/zsh-4.2.5/FAQ) 3.6:
3.6: How do I automatically display the directory in my xterm title bar?
You should use the special function `chpwd', which is called when
the directory changes. The following checks that standard output is
a terminal, then puts the directory in the title bar if the terminal
is an xterm or some close relative, or a sun-cmd.
[[ -t 1 ]] || return
case $TERM in
sun-cmd) print -Pn "\e]l%~\e\\"
*xterm*|rxvt|(dt|k|E)term) print -Pn "\e]2;%~\a"
...which does have the same problem (because you can't call chpwd on logout, as
you can't get the "previous" user/host). Personally I just do "cd ." whenever I
have that problem (which is obviously a workaround).
If you want it to "just work" the precmd solution is fine, but I wouldn't put
that in the default dot files ... even if the default files started setting the
terminal title (bash does this, so I might add it too).