How to remove the square brackets in the bash command line prompt?

obsigna

Profile disabled
I found the answer, please delete this thread.

PS: due to great demand:

cat ~/.bash_profile
Bash:
export PS1='\h:\w \u\$ '
export EDITOR=/usr/local/bin/nano
export PAGER=/usr/bin/more
export BLOCKSIZE=K

PPS: due to great public complaints:
cat ~/.bash_profile
Bash:
export PS1='\h:\w \u\$ '
...

PPPS: better delete this thread, and let _martin and/or scottro explain about the cannonical way of setting the prompt.
 
There's an old article on cracked.com, Why the guy fixing your computer hates you. They mention web searching a problem, finally finding it on a forum, then the next post is never mind, fixed it. As the author of the article says, Your new goal is to hunt down that person and kill them. :)

It is always best, even if later embarrassed for your ignorance, to leave the answer. As eternal_noob says, it might be incredibly useful to the next guy. For what it's worth, I have an old, old, article on some prompts, https://www.scottro.net/qnd/qnd-prompt.html

It's also, IMHO, better to explain irony as some people who see a post won't understand your brilliance. The only thing that has to be set is PS1 to change the prompt. In Linux, you can do this in ~/.bashrc, in FreeBSD, you can either do it in ~/.bash_profile, or have .bash_profile source .bashrc, which is what I usually do as I have a set .bashrc I can use on multiple machines. The exported settings, aside from PS1, aren't relevant to the prompt.
 
To be fair it doesn't matter if it's Linux or FreeBSD. Behavior of bash is the same here. Personally I'd set PS1 in profile, not in rc file.
For any future readers it might help, as scottro pointed out, to set PS1. Check out the manual of the bash(1), look for the "PROMPTING" paragraph.
 
Back
Top