Answer the question
In order to leave comments, you need to log in
Why isn't $HOME replaced with a tilde in bash prompt?
The essence of the problem is that the substitution of tilde instead of $HOME does not work correctly in prompt.
It is reproduced like this:
- You open the terminal (no matter which one), everything is fine.
- After changing to any folder or doing cd , the absolute path is already displayed instead of the tilde.
Visually (my prompt is two-line):
PS1="> \[\033[0;92m\]\w\[\033[0;15m\]\n\$ "
> ~
$ cd
> /home/gd
$
${PWD//${HOME::(-1)}/\~}
Answer the question
In order to leave comments, you need to log in
Here is an ancient thread https://lists.gnu.org/archive/html/bug-bash/2012-0... with a similar error due to an extra slash at the end of $HOME.
Check that you have HOME in /etc/passwd
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question