Just a quick snippet I’m using to open a new tab in Terminal. It accepts a single, optional argument which will override cd’ing to the working directory.
#!/usr/bin/env bash
if [[ $# -eq 0 ]]; then
dir=`pwd`
else
dir=$1
fi
/usr/bin/osascript \
-e "tell app \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down" \
-e "tell app \"Terminal\" to do script \"cd $dir\" in front window" \
-e "tell app \"System Events\" to tell process \"Terminal\" to keystroke \"l\" using control down"
I’ve put the shell script in “/usr/local/bin” as this is in my $PATH. I’ve named the script “tab” so whenever in Terminal I can enter “tab” to open a new tab with the current working directory ready and waiting. Very useful when working with Rails and multiple shells.
I think everyone has seen a form on a web page that has text fields that automatically empty when they receive focus. I’ve added this functionality to countless fields over the years and the behaviour I used to to this has evolved more and more. Using Prototype and the following script you can have fields intelligently empty themselves. MORE »
I’m currently working on tweaking Apple’s lazy GUI design by alphabetising VPN connections in both System Preferences and the VPN Connection menu. This is definitely only intended for Leopard and I wont be testing it in Tiger or supporting it. It’s just for my own personal use as I have 40 odd VPN connections. The initial proof of concept code is below. I still need to work on getting things to work reliably and smoothly. MORE »
If you use TextMate when you’re coding for the web you’ll probably have at least tried out Jim Jeffer’s CSS Bundle, which was inspired by an article by Jina Bolton. If not check it out!
When I first downloaded it I was impressed but not exactly blown away as the snippets don’t really leverage the true power of TextMate’s bundle system. I had to get to work to make things a lot smoother. MORE »
When I’m making a script for someone I always think it’s nice to add a bit of colour to anything output by Ruby. Not to be garish… We don’t want command line filth reminiscent of Geocities after all! But if there’s an obvious exception that ends our fun it’s good to highlight that. MORE »
I had a problem to fix a few months back where by something like 1000 users had totally bricked their home folder permissions. Trying to propagate permissions from Workgroup Manager (it was a 10.4.11 server) kept hanging and would only fix home folders up to the letter “d.” It was at this point I was called in to write a script so a colleague could repair the permissions without running the risk of annihilating the home folders from the command line. MORE »
A while back I wanted to know what people were listening to if they were sharing my iTunes library. I used lsof in a little bash script to find out. MORE »
This is an old script I’ve had lying around in my Code folder for a while now. It’s still pretty useful, even in Leopard. It basically takes a buddy’s image of your choice and uses it as your own. Furthermore, it attempts to save a copy of the buddy image on your desktop. It can be quite entertaining if not functional on occasions. MORE »
Recent Comments