0

I am on several machines running Linux Mint 20.1 "Ulyssa" - Cinnamon (64-bit), link to web, with Bash 5.0.17 as my default shell.

Today, I decided I customize my prompt and window title of my terminal emulator, which is GNOME Terminal.

I've known from the past this can be done for example per user in their .bashrc file.

As every computer has only one user + root, I went this way, I carefully read every line, to be honest, changed comments mostly.

I managed to identify and change colors to my liking. Also, the spacing where I wanted.


Relevant PS1 lines:

# Prompt:
# user @ host : full_path
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u \[\033[00m\]@ \[\033[01;34m\]\h\[\033[00m\] : ${PWD} \$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u @ \h : ${PWD} \$ '
fi

# Set the window title to the same as prompt
case "$TERM" in
    xterm*|rxvt*) PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u @ \h : ${PWD} \a\]$PS1" ;;
               *) ;;
esac

So, the only thing remaining, which I fail on for hours, is setting the Terminal window title caption, it seemingly works upon launch, but does not change if changing directory. My apologies if it is messed up. I just want it to show a full path (no tilde) wherever I am. Thank you.


Picture for the words (terminal title-bar caption not updating):

terminal title-bar caption not updating

0

For a reason unknown to me, it was only necessary to escape the $ (dollar sign) in front of PWD in the window title definition on this one line:

    xterm*|rxvt*) PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u @ \h : \$PWD \a\]$PS1" ;;

I tested it somewhat and now preparing to deploy it on all machines.

2
  • That's because the $PWD is evaluated when your .bashrc is read, so you are actually setting PS1="... \h : /your/home/ and it never changes after that.
    – terdon
    Apr 22 at 13:29
  • @terdon Feel free to update the reasoning in my answer. Thank you! Apr 22 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.