Jump to content

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


Recommended Posts

Posted

<div class="KonaBody"><p><img src="http://osxdaily.com/wp-content/uploads/2011/10/terminal-separator-timestamp.jpg" alt="Custom Terminal separator and timestamp for Bash" title="terminal-separator-timestamp" width="620" height="412" class="aligncenter size-full wp-image-21886" /></p>

<p>If you want to customize the Terminals appearance a bit <a href="http://osxdaily.com/2006/12/11/how-to-customize-your-terminal-prompt/">beyond the prompt</a> and <a href="http://osxdaily.com/2011/08/05/change-the-terminal-background-picture/">a custom background</a>, 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.</p>

<p>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:</p>

<ul>

<li>Open the Terminal and type ‘cd’ to make sure you are at the home directory</li>

<li>Backup your existing .bash_profile by typing:</li>

<p><code>cp .bash_profile .bash_profile-backup</code></p>

<li>Now open .bash_profile with nano (or your preferred text editor):</li>

<p><code>nano .bash_profile</code></p>

<li>Navigate to the end of .bash_profile and copy and paste the code below:</li>

</ul>

<p>(If you have trouble viewing the embedded code, you can <a href="http://pastebin.com/raw.php?i=cx9SqmB0">see it all here</a>)

<iframe src="http://pastebin.com/embed_iframe.php?i=cx9SqmB0" style="border:none;width:600px;"></iframe></p>

<ul>

<li>Now hit Control+O to save the changes, then hit Control+X to exit out of nano</li>

<li>Open a new Terminal window and start entering commands to see the separator</li>

</ul>

<p>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.</p>

<p>This is a pretty nice way to customize the command line a bit and make it easier to read, but it’s not nearly <a href="http://osxdaily.com/2011/05/19/termkit-terminal-reimagined-how-to-install/">as dramatic as TermKit</a> or some of the other crazier options out there. </p>

<p>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 <a href="http://lifehacker.com/5840450/add-a-handy-separator-between-commands-in-your-terminal-on-mac-os-x-and-linux">Lifehacker</a> modified from <a href="http://emilis.github.com/2011/09/12/customized-bash-prompt.html">Emilis Dambauskas</a>, 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.</p>

</div>

<p><a href="http://feedads.g.doubleclick.net/~a/fmHoFDpKeGbTzZYnOQc7Rp2hAeA/0/da"><img src="http://feedads.g.doubleclick.net/~a/fmHoFDpKeGbTzZYnOQc7Rp2hAeA/0/di" border="0" ismap="true"></img></a><br/>

<a href="http://feedads.g.doubleclick.net/~a/fmHoFDpKeGbTzZYnOQc7Rp2hAeA/1/da"><img src="http://feedads.g.doubleclick.net/~a/fmHoFDpKeGbTzZYnOQc7Rp2hAeA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">

<a href="http://feeds.feedburner.com/~ff/osxdaily?a=N36HWRyF3Ec:uXS9UP8cekU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=N36HWRyF3Ec:uXS9UP8cekU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/osxdaily?i=N36HWRyF3Ec:uXS9UP8cekU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=N36HWRyF3Ec:uXS9UP8cekU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/osxdaily?i=N36HWRyF3Ec:uXS9UP8cekU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=N36HWRyF3Ec:uXS9UP8cekU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=N36HWRyF3Ec:uXS9UP8cekU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=qj6IDK7rITs" border="0"></img></a>

</div><img src="http://feeds.feedburner.com/~r/osxdaily/~4/N36HWRyF3Ec" height="1" width="1"/>

 

View the full article

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days


×
×
  • Create New...