OSX: Toggle hidden files in Finder

Here's a little shell script I knocked up for toggling hidden files in finder. Running from the Finder toolbar To have this to hand from within finder you can create an application in Automater. Just select run shell script and paste the contents of this script. Save it as an…

BASH: Using brace expansion

There's a nice feature of BASH which is to use a comma delimited list of strings inside of curly braces to reduce the amount of typing: here's an example of using brace expansion to create log files for apache: sudo touch {access,error}.log Something seen less often is a…

Bash: turn on case-insensitive tab completion

I always forget this one, but it's dead handy as it allows you to type "py" hit tab and it will auto complete for "Python" or "python" for example. Without this setting you'd have to type explicitly what you want. To enable run: echo…

Bash: Resolving Symlinks to Shellscripts

Here's a way to resolve symlinks that call a bash shellscript. The Problem I like to be able to use something like this in my bash scripts: SCRIPTDIR=$(dirname $0) Which is great for a reference to where the script is, but it suffers from the problem that if you…

pwdn: show last n dirs of current directory

I've been playing around with some scripts of late to automate delivery of my various scripts and aliases to servers and in doing so I was looking back at the code I am calling to display the last two directories in my bash prompt. It made me think; why don't…

Django: Switching between development branches

Cyril and I have been using new forms admin for some stuff we are working on for fun whilst we are here at SXSWi. One of the issues is that if you're developing several different Django sites you won't necessary want to migrate away from trunk to migrate everything to…

Using 'select' for multiple choices in shell scripts

I found this neat construct in the gnu bash reference. Select is a great way to be able to present a list of options to a user in a shell script. Take the example given in the reference: select fname in *; do echo you picked $fname \($REPLY\) break; done This…