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: 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…

BASH Tip: Alternative to expr for arithmetic

I discovered recently a neat way to do arithmetic in BASH without the need to use the expr command. There's a build-in that uses the syntax $((…)) or $[ … ]. This is also faster as it avoids the need to invoke a separate command. See: http://snap.nlc.dcccd.edu for more on…