Bash – How to escape an exclamation point in the PS1 environment variable

bashpromptquoting

It is substituted with the history number even if I try to escape it with a backslash.

Best Answer

There's no need to escape it if you just want an exclamation mark in the prompt.

PS1='foobar!'   

See what happens.

Related Question