February 26th, 2005
So you’ve just installed Linux, and you’ve lost some of the little configuration files you forgot to backup, and you can’t quite remember what you put in them - or where you put them. And all the time you spend hunting around, touching and editing various files, you are confronted with an annoying ugly Bash prompt. So what to do? Pretty easy actually. First check if you have a .bashrc file in your home (~) directory:
cd ~
ls -a | grep .bashrc
If you do, then make it look like this with vi:
vi .bashrc
i
PS1="u[@Hw[$ "
Esc :wq Enter
If not create a ready to use .bashrc:
cd ~
echo PS1="u[@Hw[$ " > .bashrc
Now fire up another shell. Neato eh? What this does is print out your username, computer, and path (instead of pwd all the time) with a dollar and space. Not neato? Well have a look at the alternatives. Edit the .bashrc file as required using vi as above to tailor your prompt.
There is another, slightly more efficient, way of creating this effect using the .bash_profile but for reasons as explained here, it doesn’t always work. Just use the .bashrc to avoid annoying behaviour.