Paul Calnan
Published February 15, 2013

My Bash prompt has progressively gotten more complicated over the years. Today, I wanted to add to it and realized it was time to reorganize.

Prior to today, it looked like this:

export PS1="\n\[\e[0;33m\]\D{%a %b %d %T %Z %Y}\[\e[0;34m\]\$(__git_ps1)\n\[\e[0;31m\]\u@\h\[\e[0m\]: \[\e[0;36m\]\w\[\e[0m\]\n$ "

After today's reorganization, it now looks like this:

    if [ "$VIRTUAL_ENV" != "" ]; then
        echo -n "$(basename $VIRTUAL_ENV) "

__PS1_DTS="\[\e[0;33m\]\D{%a %b %d %T %Z %Y}"

if [ -e "$__RVM_HOME/bin/rvm-prompt" ]; then
    __PS1_RVM="\[\e[0;31m\]\$(rvm-prompt i v p g)"

__PS1_USERNAME="\[\e[0;31m\]\u@\h\[\e[0m\]: "

export PS1="\n${__PS1_DTS}${__PS1_GITSTATUS} ${__PS1_PYENV}${__PS1_RVM}\n${__PS1_USERNAME}${__PS1_PWD}\n$ "

Here's a screenshot of it in action:


Maybe it's too much information, but I find it useful. On the first line, the date is in yellow. My current Git branch is in green. My current Python virtual environment is in purple. My current Ruby version, patchlevel, and gemset is in red. On the next line, my username and hostname are in red, and my working directory is in blue.

To show the Git branch, you need to have the Homebrew bash-completion package installed, and you need to do the following in your .bashrc:

if [ -f /usr/local/etc/bash_completion.d/ ]; then
    source /usr/local/etc/bash_completion.d/