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="[33[0;30m]"
BLUE="[33[0;34m]"
VIOLET="[33[1;35m]"
CYAN="[33[0;36m]"

PS1="n[$CYANu@h:$BLUEw$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="nu@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="[33[1;35m]"
NO_COLOR="[33[0;0m]"  

PS1="n$VIOLETu@h:w  $(parse_git_branch)$NO_COLORn$ "

See. I told you it was "tweaking."

Google Docs Backup with GDocBackup

I was searching for a simple way to make local backups of my Google Docs and found gdocbackup on Google Code. According to the project docs it runs on Windows and Linux (with Mono) so I tried it on both Windows 7 and Ubuntu 9.10 Desktop.

On the Windows 7 PC, I downloaded the installer from the Google Code project page, installed the application, and ran it. After configuring the backup directory and export formats for the documents I executed the backup and it worked fine.

Running it on Ubuntu took a bit more setup since I did not have Mono installed. First I installed the required Mono packages.

sudo apt-get install mono-runtime libmono-winforms2.0-cil mono-devel

The mono-devel package installs the mozroots utility needed to install a certificate required to access Google Docs (see http://gs.fhtino.it/gdocbackup/faq).

Next I imported the Mozilla root certificates into Mono (see http://manpages.ubuntu.com/manpages/intrepid/man1/mozroots.1.html).

mozroots --import --sync

I downloaded GDocBackup_0.4.9.71_BIN.zip from the gdocbackup project’s Downloads page and extracted it to a GDocBak directory I created in my home directory. I also created a Data directory under GDocBak to hold the backup files. I opened a terminal in the GDocBak directory and ran GDocBackup.exe in Mono.

mono ./GDocBackup.exe

At this point the GDocBackup application worked the same as in Windows 7. It looks a little different but it downloaded the documents without errors. Now I just need to automate the backups.

Bookmarks Selective History

Some folks don’t keep bookmarks in their browsers anymore since you can always use a search engine to find things when you need them. Problem is, often the thing that interests me is not one of the top items in a search result set (even when I can remember the right search terms to use). If I’m looking for a specific thing I saw before I’m probably not going to be satisfied with search results showing me similar things but not that specific thing. I still use bookmarks.

I used to try to put bookmarks into folders based on category. That’s labor intensive always sorting out a categorization every time I create a bookmark. What I’ve been doing lately is this: When I first open Firefox (doesn’t have to be Firefox but that’s my main browser) I create a folder in the Bookmarks Toolbar named for the date such as 20090901. That folder is where I’ll drop any bookmarks collected during the day. I will also review the previous day’s folder for any items that I want to move to a category folder I already have (usually don’t move any). I then move the previous day’s folder to a folder named SelectiveHistory that is one level down from the Bookmarks Toolbar under a folder named Bill.

selectivehistoryexample3

This has been working well. I have found that when I want to go back to a web page it is more likely to be a recent one so I don’t usually have to browse back too far in my SelectiveHistory. Firefox makes it easy to browse the bookmarks tree by simply hovering the pointer. I can also choose Tools – Organize Bookmarks to open the bookmarks Library and do a search when looking for something not so recent.

I do some maintenance on the SelectiveHistory folder by moving the daily folders into a previous month folder and monthly folders into a previous year folder. Doing so takes little time and not a lot of thought (easy enough to do before the coffee kicks in). I should also mention that I use Xmarks to synchronize my massive bookmarks collection across the computers I use Firefox on frequently. I really should mention that, because I don’t think my method of collecting bookmarks described above would work nearly as well without synchronization.