I am using Gnome 42.3 (in Manjaro).
After some Google search, I was confused by the many answers so I tried to sort out what actually worked.
This works immediately in zsh:
precmd () {print -Pn "\e]0;%n@%m: %~\a"}
You can put in in ~/.zshrc
.
precmd
runs before every prompt, ensuring updating after cd
.
This works immediately in bash:
PROMPT_COMMAND='echo -ne "\033]0;$(whoami):$(pwd)\007"'
You can put in in ~/.bashrc
.
This feature is very useful
I have a deep file system with long directory names so if I display current directory in shell prompt then most of the terminal is filled with copies of the current directory name, so I need to have the information somewhere else and the menu bar is available therefore.
Also, I often work with many terminals, each one with different working directory, so, if the working directory is not displayed, I am lost.
Remark
I use X11, I doubt it will work with Wayland.
${USER}@${HOSTNAME}:
if you just want the pwd – Lobbyism