Color Coded Bash Prompt

This post explains what I’m referring to by color coded bash prompt, why it is useful to have one, and presents an implementation.

By color coded bash prompt, I am referring to the use of colors to represent aspects of the environment running bash. An ordinary bash prompt may display a username and hostname. Color coding can be used to represent whether the user is root, whether the session is running on a local or remote machine, and other aspects of the environment (not covered in this post).

When running multiple terminals at the same time, with some connected to remote machines and/or running as root, color coding makes it easier to keep track of the sessions, and may help prevent inadvertently entering a command as root or on the wrong machine.

I have configured my bash prompt’s colors to be a function of whether I am running as a root or non-root user, and whether I am connected to a local or remote machine. The username is displayed in green for a non-root user and in red for the root user. The hostname is displayed in blue for a local bash session and in cyan for a remote session.

The following image shows the four possible scenarios, 1) on a local machine as a non-root user, 2) on a local machine as root, 3) on a remote machine as a non-root user, and 4) on a remote machine as root.



recrun Chrome Extension

recrun is a Chrome extension I developed to provide a clean interface for reading articles on the web. recrun is an acronym that stands for retain essential content, remove unwanted noise. It uses the Diffbot Article API to extract relevant content from article pages.

The extension can be downloaded at the Chrome Web Store and the source code is available at Github.

A Diffbot token is required to use the extension. A free token can be obtained by signing up at


  1. Install the extension
  2. Sign up for a Diffbot API token
  3. Navigate to an article web page
  4. Click the eyeglasses icon in the Chrome toolbar (see arrow in image below)



Bar Charts for Hacker News Polls

Update 10/14/2013: The tool is now available as an extension on the Chrome Web Store.

I was recently viewing a poll on Hacker News and thought it would be useful to visualize the results of the poll, so I wrote a script for generating bar charts. The image below shows an example.

Bar Chart Example


Assorted Links

  1. Sebastian Thrun on Charlie Rose, April 25, 2012 (click image to play video)
  2. 10 Things Your Commencement Speaker Won’t Tell You – here’s an idea from the article: “Read obituaries. They are just like biographies, only shorter. They remind us that interesting, successful people rarely lead orderly, linear lives.” Here’s the New York Times Obituaries page: NY Times Obituaries.

Changing Mac Key Bindings

This post explains the steps I took to make my Mac keyboard work more like a PC keyboard. The goal here is not necessarily for keys with the same names to be in the same position (e.g., the Ctrl key), but rather to have the same functionality across platforms when pressing keys located in the same positions.

Until last summer, I mainly used Windows and various distributions of Linux. Last summer I got my first laptop, a MacBook Air. I still use Windows on my desktop computer, and I have Xubuntu installed on VirtualBox virtual machines on both my desktop and laptop.

Both Windows and Linux (i.e., the distributions that I have used) have similar key bindings. For example, Ctrl-C is used for copying on Windows and it is also used for copying on every desktop environment I have used on Linux. When I started using OS X, I quickly realized that it uses a different set of key bindings. For example, the key binding for copying is Command-C, and the Command key on a Mac keyboard is located in a different position than the Ctrl key is on a PC keyboard.