Blue Cog Blog Rotating Header Image

July, 2010:

PyOhio Attendee Wannabe

PyOhio badge

Yeah, the badge says “attendee” but it turns out I have a conflict this year and won’t be attending. It’s a family matter that could not be rescheduled, and it’s important to me, so I will have to miss out on a terrific event around the Python programming language. I made it to one day of the two day event last year and was really hoping to make it for both in 2010.

So if for some reason you are reading this blog, and you have even the slightest interest in Python, and you will be in the Columbus area on July 31st and/or August 1st, you really should check out PyOhio. I would. Alas, maybe next year.

Tweaking the Bash Prompt

A little Saturday morning tweaking.

Based on this post at railstips.org, I decided to adjust my Bash prompt by appending the following to my ~/.bashrc file:

#...

function parse_git_branch {
  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  echo "("${ref#refs/heads/}")"
}

BLACK="\[\033[0;30m\]"
BLUE="\[\033[0;34m\]"
VIOLET="\[\033[1;35m\]"
CYAN="\[\033[0;36m\]"

PS1="\n[$CYAN\u@\h:$BLUE\w$VIOLET \$(parse_git_branch)$BLACK]\n\$ "

The prompt will now show the name of the branch I am working in when the current directory is part of a Git repository. The original code used yellow, red, and green to highlight parts of the prompt. That messed with my mind when I ran RSpec and saw yellow and red when I was expecting all green. Rather than get used to it, I changed the colors. I also added some newlines to perhaps keep the command line neater when deep in a directory tree.

Terminal screen shot

 

[Update 2010-07-23]

After running with the above settings for a while I decided I don’t care for the colors in the prompt. Don’t need the square brackets either. I do like seeing the current git branch. That simplifies things a bit.

#...

function parse_git_branch {
  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  echo "("${ref#refs/heads/}")"
}

PS1="\n\u@\h:\w  \$(parse_git_branch)\n\$ "

 

[Update 2010-09-25]

Okay, maybe a little color…

#...

function parse_git_branch {
  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  echo "("${ref#refs/heads/}")"
}

VIOLET="\[\033[1;35m\]"
NO_COLOR="\[\033[0;0m\]"  

PS1="\n$VIOLET\u@\h:\w  \$(parse_git_branch)$NO_COLOR\n\$ "

See. I told you it was "tweaking."