Current git branch and git autocompletion in bash

First put the following script somewhere, like ~/ and chmod +x it.

Then add this line to your ~/.bash_profile:

. ~/

Finally, if you want to pretty up your prompt as above, then add this:

export PS1=’\h:\W \[\e[1;32m\]$(__git_ps1 “[%s]”)\[\e[0m\] > ‘

You can also install git from (Thanks Jon)

Or on ubuntu install a package called “git-completion” (Thanks Juan)


A proper shell in windows

Thanks to a posting on our mailing list I am trying out mintty, a tty shell emulator for windows which runs on top of cygwin.

So far so good, feels like the real deal.

You can install it by running “setup.exe” in the cygwin folder and install it from the package list under “shells”.

I added a couple of lines to my ~/.bash_profile

export PS1="\W> "
alias clear='echo -e "\033c"'

As there didn’t seem to be a default “clear” command to clear the terminal. Got the trick from here. Also good is The tips and tricks page

To get a nice “Bash prompt here” you can install the chere package from the cygwin setup (same as above) and then run:

chere -i -c -t mintty -s bash

One oddity I’ve found is that if you execute a batch file which uses CMD.exe, CTRL+C doesn’t seem to work. It breaks out of the program but then output still appears! So you need to run .sh files in there.


Colorised Build Success Message

My current project has a neat trick we picked up where the build has a red or green banner at the end when you run it locally to give good feedback about the build status. I’m not sure who originated it, but thanks!

I just had to tweak it a bit to get it working on OS X so I thought I would document the trick here. - OS X

CMD=”./tools/ant/bin/ant -lib ./asl/lib/jdepend $@”
echo “Running command [${CMD}] …”
if [ “$?” -ne 0 ]; then
    echo -e “`tput setab 1`  `cat ./ci/failed.txt` `tput setab 0`”
    exit 1
    echo -e “`tput setab 2`  `cat ./ci/passed.txt`  `tput setab 0`”
    exit 0

This assumes you have two supporting files ./ci/passed.txt and ./ci/failed.txt which contain the message. You can generate messages to your taste here.

I have provided the files in this example here :



It has also been run under Ubuntu where the following works (it didnt work on OS X which is why I adapted it), but the tput should also work on Ubuntu. I’ve not explicitly tested this one!

if [ “$?” -ne 0 ]; then
    echo -e “\E[30;41m”
    cat ./ci/failed.txt
    echo -e “\E[0m”
    exit 1
    echo -e “\E[30;42m”
    cat ./ci/passed.txt
    echo -e “\E[0m”
    exit 0

Under windows you can actually make the entire screen of the terminal change color:

run.bat - WINDOWS

CALL tools\ant\bin\ant %*
color 4F
color 2F
color 07

Edit GMail messages using Vim

Ok, why would you want to do this ?

Because you can.

1) Install this add-on which allows you to edit text areas in firefox using an external editor:

2) Install VIM

3) Setup the plugin to use vim (addOns->its all text addon->options)

4) make sure gmail is using “plain text” as editing – otherwise its not a text area, but some mad iframe.

6) Happy Days!