How to avoid tilde ~ in Bash prompt?
I would like to remove the tilde from displaying within the PS1 variable.
My current PS1 string:
PS1="\h:\w\n$"
And the prompt looks like this:
lnx-hladky:/tmp/plugtmp
$
I don't like that the $HOME directory is displayed as tilde. Can this be avoided?
It causes problems, example:
lnx-hladky:~/DOC
$
Documentation says:
\w : the current working directory, with $HOME abbreviated with a tilde
\W: the basename of the current working directory, with $HOME abbreviated with a tilde
Is there any possibility to avoid $HOME being abbreviated with a tilde?
I have found one way around but I feel like it's overcomplicated:
PROMPT_COMMAND='echo -ne "\e[4;35m$(date +%T)\e[24m$(whoami)@$(hostname):$(pwd)\e[m\n"'
PS1=$
Can anyone propose a better solution? I have a feeling it's not quite OK to run so many commands just to get prompt. (date,whoami,hostname,pwd).
bash runs expansions in the prompt; just make sure to escape them.
PS1='\h:$(pwd)\n$'