How annoying is it when the path gets so long that you can’t type pwd without
breaking to a new line? Or when you scroll up through history and all your commands
seem to blend together? Madness!
The default prompt format:
MyLaptop:~/Desktop/AwesomeStuff/2015/08/16/OhManILoveThisStuff/Really/How/Far/Can/We/Go johndoe$
You can clean up the default prompt pretty easily. Join the revolution and put
this in your ~/.bash_profile:
export PS1="\n\h:\u \w\n\$ "
The result has a line break before the hostname and another after the path. That way you can divide up your commands nicely for scrollback, and you’ll have a full line to type on. Here’s how it looks:
[… last command…]
MyLaptop:~/Desktop/AwesomeStuff/2015/08/16/OhManILoveThisStuff/Really/How/Far/Can/We/Go johndoe
$ echo "I can type sooooooo much stuff here!"
We can improve on that and give it some flavor.
LEETUSER=`whoami | tr abcdefghijklmnopqrstuvwxyz 48\(\)3\|6#1jk\|mn0pqr57uvwxy2`
CURDATE=$(date +"%b.%d.%Y @ %I:%M%p")
export PS1="\n$LEETUSER|$CURDATE|\w\n\$ "
The result:
j0\#n)03|Jul.15.2014 @ 11:39am|~/Desktop/AwesomeStuff/2015/08/16/OhManILoveThisStuff/Really/How/Far/Can/We/Go johndoe
$ echo "I'm l33t, )4w6!"
You could add some color to it with the opening tag \[\e[1;32m\] and close
color with the closing tag \[\e[0m\]. You could also separate the values with
` ::: ` to make them easier to read:
LEETUSER=`whoami | tr abcdefghijklmnopqrstuvwxyz 48\(\)3\|6#1jk\|mn0pqr57uvwxy2`
CURDATE=$(date +"%b.%d.%Y @ %I:%M%p")
export PS1="\[\e[1;32m\]\n$LEETUSER ::: $CURDATE ::: \w\n\$\[\e[0m\] "
The resulting prompt will be green!
Perhaps you just want to simplify things with a $ and a space:
export PS1="\$ "
The result:
$ echo "I know how to type pwd and date, and I never change users, so whatevz."
There’s an endless number of possibilities — have some fun!
Sources: