There are lots of tutorials on the internet defining what the best Ubuntu command prompt is, and I’ve worked through a lot of them. They all seem to have a similar format: username, then the folder you’re in (some also add the time, the history number of that command, and a list of Henry VIII’s wives… but that’s going a bit too far..)
If you’ve used a command prompt, you can see the issue already; when in a deep folder structure, you end up with all your command space being taken up by the prompt, and there’s no space left for any actual commands.
For example, the command
export PS1='[\H]:[\u]\d\t[\w][\!]\$ '
Will give you this command prompt:
As you can see, there isn’t much room left for actually doing any work.
So, without any further ado, here’s my solution;
export PS1='[\w]\n\u\$ '
This gives a prompt as follows;
You can see that we don’t care about the time or date or history number (a decent clock and typing ‘history’ will give you that information). We do get the current folder – on a line of it’s own, for when it gets long. We also get the username, and a prompt showing whether we are root (#) or a normal user ($). For me, that’s all useful information, and nothing we don’t need. And I now have lots of space to enter my commands in.
How to keep the command prompt
One minor issue to entering the command prompt at the command line, as above. It will disappear next time you log on.
Simple solution: Edit the .bashrc file in your home folder, and at the very bottom of that file, enter
export PS1='[\w]\n\u\$ '
Save the file and log out. When you next log in, you’ll see the new command prompt in all its glory.