Sample Header Ad - 728x90

Full path in terminal prompt and title-bar with modified PS1 in .bashrc

0 votes
1 answer
1579 views
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:
-sh
# 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
Asked by Vlastimil Burián (30515 rep)
Apr 22, 2021, 11:29 AM
Last activity: Apr 22, 2021, 12:55 PM