In Ubuntu 18.04 and 22.04 (WSL), I've noticed that
$PS1
contains a "bell" character, \a
:
$ echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
#I then use sudo su to become root:
# echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
Note the \a
before the closing square bracket in both of the above.
I have also noticed this in Kali, back in January:
$ echo $PS1
\[\e]0;\u@\h: \w\a\]\[\033[;32m\]┌──${debian_chroot:+($debian_chroot)──}${VIRTUAL_ENV:+(\[\033[0;1m\]$(basename $VIRTUAL_ENV)\[\033[;32m\])}(\[\033[1;34m\]\u㉿\h\[\033[;32m\])-[\[\033[0;1m\]\w\[\033[;32m\]]\n\[\033[;32m\]└─\[\033[1;34m\]\$\[\033[0m\]
and in msys2 ucrt64 running on a Windows PC.
There seems to be no reason for this character to be present, especially as no "bell" sound is actually output when the prompt is displayed. And I'd find it very annoying if such a sound was played! So what is the reason for its presence in these $PS1
variables?
Asked by AJM
(295 rep)
Dec 14, 2023, 03:25 PM
Last activity: Dec 14, 2023, 04:14 PM
Last activity: Dec 14, 2023, 04:14 PM