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

Oct 3, 2011 - 16 Comments

Custom Terminal separator and timestamp for Bash

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:
  • cp .bash_profile .bash_profile-backup

  • Now open .bash_profile with nano (or your preferred text editor):
  • nano .bash_profile

  • Navigate to the end of .bash_profile and copy and paste the code below:

(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.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: AJ in Command Line, Customize, Mac OS X, Tips & Tricks


» Comments RSS Feed

  1. Bink of Boldhome says:

    Seriously? This is a superb reason that most Mac users should never be permitted to run or X11. Stay away from the keyboard and stick what you know: your MOUSE.

    • sparky says:

      surely you don’t speak for everyone when you proclaim, “don’t dare learn anything new! get back to your bucket of lard, slackers!”

  2. robbedoes says:

    I get an error:

    cp: .bash_profile: No such file or directory

    • AJ says:

      In that case, skip right to nano .bash_profile and it will create the file for you.

      • Cr3at3 says:

        @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.

  3. robbedoes says:

    file was created but nothing happens

  4. sparky says:

    inefficient fill routine. try:

    fill=$(/usr/bin/jot -s \- -b \- $fillsize)

    instead of that while/do loop.

  5. Apprentice says:

    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:

    Try it and see if you like it.

  6. Chris says:

    Nice overview. Horrible PS1. Glad you like it… Been doing unix for 15 yrs. Like it minimal… Username and pwd … Drop that godawful separator!


  7. Nuk says:

    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?


  8. Tom S says:

    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?

  9. jose says:

    nifty. but do not want the full PWD printed out…how can we leave it how it was and just add the timestamp?


  10. that dude says:

    This is horrible. There is too much fluff in this. All that was explained was a separator and a time stamp. Which I could write in a few lines.

Leave a Reply


Shop for Apple & Mac Deals on

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates