Mac OS X tweaks

Here’s a few Mac OS X tweaks I usually make on any new system I use…

1. LS

The default output of “ls” (for listing files and folders) isn’t great — but add a few switches, and it becomes much more helpful…

ls -l -F -G

But who want to remember and type that every time? Just add:

alias ls=’ls -l -F -G’

to your .profile file (in your home folder) and every time you type “ls” it’ll automatically use those switches.

2. TAB autocompletion

As you’re typing file or folder names, TAB autocompletion is great. But whoever thought it should be case sensitive must be more pedantic than me. To make TAB autocompletion case insensitive, just add this to your .inputrc file (in your home folder).

set completion-ignore-case On
TAB: menu-complete

3. Mac OS X font smoothing

There’s been quite a bit of chatter about how Mac OS X 10.6 (and up) renders text – making it look a little blurry. It’s quickly fixed by running this:

defaults -currentHost write -globalDomain AppleFontSmoothing -int 2
killall Finder

The 2 on the end is for medium smoothing which used to be called “best for flat panel”, 1 is for light smoothing, and 3 is for strong smoothing. After you execute the command you can either restart or quit and reopen any apps (including Finder).

4. Add CWD to default path

Bored of adding ./ to the front of all your commands? Simply add . to the front of the default path in the .profile:

export PATH=.:$PATH

Don’t forget the export – that makes the environment variable change visible outside of the script.

5. Quick introduction to ‘find’

The find command is quite simply awesome – but looks really complicated until someone shows you how to use it. The basic form is:

find <starting point> <flags>


find .

will list all files and folders recursively from the current position. Stay tuned:

find . -name “*.txt”

will list all files whose name ends in .txt

find . -name “*.txt” -type f

will exclude folders, symlinks and device special files by indicating that only files of type ‘f’ should be returned. Ok – now things get groovy:

find . -name “*.txt” -type f -exec cat {} » newfile.txt ;

WTF? Ok – calm down… the -exec treats the remainder of the line as a command to run against each file found. In this case we are going to conCAT all the files together to a file called newfile.txt. The {} notation is a placeholder for the item found, and the ; indicates the end of the command. Because this is a special character it must be escaped.

Using this you can rename, move, generally monkey about with a tree of files from a single command. In conjunction with grep and sed this makes bash far more powerful than a standard Windows command prompt.

I leave you with this:

find . -name “filename” -exec mv {} echo {} | sed s/^/new/ ;

Commands in back apostrophes are executed first, and the results are fed back into the command – a bit like parentheses. Any guesses what this command does?