Add a Separator & Time Stamp Between Terminal Commands to Increase Readability

If you want to customize the Terminals appearance a bit beyond the prompt and a custom background, you can make the Terminal much more readable by using this nice trick to add a separator and timestamp between each executed command. This also bolds the current command text and anything that is available from tab completion.
To get this to work, you just need to paste a script into your .bash_profile. Here’s how to do this, including how to make a backup of your existing bash profile in case you mess something up:
- Open the Terminal and type ‘cd’ to make sure you are at the home directory
- Backup your existing .bash_profile by typing:
- Now open .bash_profile with nano (or your preferred text editor):
- Navigate to the end of .bash_profile and copy and paste the code below:
cp .bash_profile .bash_profile-backup
nano .bash_profile
(If you have trouble viewing the embedded code, you can see it all here)
- Now hit Control+O to save the changes, then hit Control+X to exit out of nano
- Open a new Terminal window and start entering commands to see the separator
Remember if you want to revert this you can either delete the code from bash_profile or just go back and replace it with your backed up copy, named .bash_profile-backup and located in your home directory.
This is a pretty nice way to customize the command line a bit and make it easier to read, but it’s not nearly as dramatic as TermKit or some of the other crazier options out there.
As long as you’re using bash you should be able to do the same with other variations of unix too. This is a cool little trick that Lifehacker modified from Emilis Dambauskas, you can get a different variation for Linux at either of those sites if for some reason this one doesn’t work for you. Thanks to Marcus for sending this to us.

Seriously? This is a superb reason that most Mac users should never be permitted to run Terminal.app or X11. Stay away from the keyboard and stick what you know: your MOUSE.
surely you don’t speak for everyone when you proclaim, “don’t dare learn anything new! get back to your bucket of lard, slackers!”
I get an error:
cp: .bash_profile: No such file or directory
In that case, skip right to nano .bash_profile and it will create the file for you.
@AJ – Normally if .bash_profile doesn’t exist it usually has the name .profile instead, or .bashrc
@robbedoes – just type ‘find .profile’ or ‘find .bashrc’ if it says that one of the two exists just edit the one it found.
file was created but nothing happens
You must use bash shell and open a new Terminal
inefficient fill routine. try:
fill=$(/usr/bin/jot -s \- -b \- $fillsize)
instead of that while/do loop.
What does your .bash_profile look like? Did you add the code starting on a new line?
OSXDaily is a good web site that I have learned much from it. For this subject, I would like to contribute a little with my personal setting. You can see my setting here:
http://lion.ee.ntu.edu.tw/~hylin/term.html
Try it and see if you like it.
I like the colours, but where do I put it in the above code to make it work?
Nice overview. Horrible PS1. Glad you like it… Been doing unix for 15 yrs. Like it minimal… Username and pwd … Drop that godawful separator!
Aloha!
Hmm, I like it but I’d rather not have the fontface in bold. How do I change it to regular?
Also, my terminal screen is deep blue, how can I have the separator bar in white?
TIA
Works great and is incredibly useful for admin tasks on my MacBookPro 10.6.8 Does not work for 10.5.8. Could you post a modified version? Would this work in Lion / Mountain Lion?
nifty. but do not want the full PWD printed out…how can we leave it how it was and just add the timestamp?
thanks