Monthly Archives: August 2009

git branch management scripts

A couple of scripts I (very) quickly wrote for managing git branches, so I don’t have to keep reading git cheat. No error checking or intelligence in the scripts – YMMV.

Delete a tracking branch both locally and remotely:

% cat gitkillbranch
#!/bin/bash

asksure() {
echo -n "Are you sure (Y/N)? "
while read -r -n 1 -s answer; do
 if [[ $answer = [YyNn] ]]; then
 [[ $answer = [Yy] ]] && retval=0
 [[ $answer = [Nn] ]] && retval=1
 break
 fi
done
echo
return $retval
}

echo
echo "*********************************************************"
echo "This will delete the branch $1 both locally and remotely."
echo "*********************************************************"
echo

if asksure; then
 echo "sure"
 git br -d $1
 git br -r -d origin/${1}
 git push origin :${1}
else
 echo "Not deleting"
fi

Track all remote branches locally:

% cat gittrackall
#!/usr/bin/ruby

result = `git br -r`
result.each do |line|
 line.chomp!
 branch = line.split('/')[1]
 next if branch =~ /HEAD|master/
 puts branch
 `git branch --track #{branch} origin/#{branch}`
end

Installing Aptana + RadRails on Ubuntu Jaunty

I’ve always used vim as my main editor, but I thought I’d try RadRails since so many Rails people rave about it. Installing it on Ubuntu Jaunty is a bit non-obvious:

  • sudo aptitude install openjdk-6-jre (or your preferred jre)
  • download and unpack aptana zip to ~/.aptana
  • download and unpack xulrunner to ~/.xulrunner
  • create a script like ~/bin/aptana:
#!/bin/bash
MOZILLA_FIVE_HOME=~/.xulrunner
if [ $LD_LIBRARY_PATH ]; then
    LD_LIBRARY_PATH=$MOZILLA_FIVE_HOME:$LD_LIBRARY_PATH
else
    LD_LIBRARY_PATH=$MOZILLA_FIVE_HOME
fi
export MOZILLA_FIVE_HOME LD_LIBRARY_PATH
~/.aptana/AptanaStudio -vm /usr/lib/jvm/java-6-openjdk/bin

[ubuntu] Installing Aptana on Jaunty – Ubuntu Forums

Ubuntu and Toshiba Satellite Pro L300 fan

I recently bought a new laptop – a bottom of the range Toshiba Satellite Pro L300 costing $780 (extra RAM pushed the price up). I used to buy high-end laptops but my thinking was changed when my latest one got stolen and I started using an old one I’d (literally) dredged out of a rubbish bin. I mostly use shell/vi/ssh, Thunderbird and Firefox, don’t carry my laptop around with me, and all my stuff is backed up across multiple machines using git, so why shell out the big bucks?

So far I’m liking the Satellite Pro. Ubuntu 9.04 installed without a hitch, sound and wireless worked straight out of the box, the keyboard has a nice feel to it and all the keys are in the proper places (unlike Dell laptops that seem to scatter them all over the place).

Only problem was the fan. The poor little cpu is a bit underpowered so the cpu load average continually sits on or above 1, and the fan was going mental. A quick search on Google found the solution: in /boot/grub/menu.lst change defoptions to

# defoptions=acpi_osi="Linux"

run sudo update-grub, reboot.