Probably the best PS1 in the world

If you use the shell a lot, you probably have a prompt that contains a host name and current working directory. Both are essential for navigation, especially if you work on multiple servers.

But these can get quite long, so the $ is half way along the screen before you even start typing. So even with a moderate command, you often wrap onto the second line which makes syntax harder to judge and check.

I changed my PS1 in the .bash_aliases file so that it prints the host name and working directory, but then does a new line before the $. So I have an entire terminal width to type every command.

Here’s the code:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\n\[\033[01;32m\]\$ \[\033[00m\]'

The important part is the \n before the \$. All the other stuff is to do with colouring, making the host name and prompt green and the working directory blue. I haven’t the faintest idea what those codes are though, I just copied them from the ubuntu default (probably something to do with the VT100, knowing unix)

I make this change on all new machines I work on for any period of time. It’s probably the best PS1 prompt in the world.

But let me know if you have a better one.

Read more on this topic . . .