Archived Mac & OS X Uncategorized

Make the OS X Dock nice and tidy…

I’m bit a of a tidy-freak when it comes to icons, desktops and overall system organisation … geeky? Yes. Easier to work with afterwards? Definitely.

So now that I’m using a Mac I’ve been slowly getting used to organising things better – including the Dock. I’ve got everything ordered how I want but still thought it was a bit of a mess (visually) so I tried to find a way of adding some space to the Dock, thereby creating ‘groups’ of Dock icons. Yes, I know about stacks but they didn’t do what I wanted.

All you need to do is run a pretty simple shell script to get it done. There are 2 scripts to use, one for the Applications side of the Dock and the other for the Documents side of the Dock. By ’side’ I mean the parts of the Dock on the relevant side of the existing resizer/splitter thingy.

Shell script I hear you say? Bad! Well … no, not as bad as you might think. Thankfully OS X has a built-in scripting language all of its own called … wait for it … AppleScript. From AppleScript you can run shell commands which you don’t even need to mess about in the shell if you don’t want to. For the Windows people out there think of this example as a batch file – the end result is the same.

Anyway, fire up the AppleScript Editor (it’s under Applications/Utilities if you haven’t moved it) and paste the following script into it. Note that this one is to add a spacer to the Application side of the Dock!

Add a spacer to the Applications side of the dock:

-- add a spacer to the Application side of the Dock
do shell script "defaults write persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'"
-- restart the Dock
-- process names are case-sensitive!
do shell script "killall Dock"
Archived Mac & OS X Uncategorized

Reloading hosts files in OS X

Now that I’m using a Mac at home I’ve had to go through a bit of a mind switch when it comes to doing things I’ve been to doing for years.

Today’s mind bender came about because I needed to edit the hosts file to force Snow Leopard to find a URL on a different IP address to where it actually is. In Windows you just edit %SystemRoot%system32driversetchosts then run nbtstat -R to reload the hosts file but in OS X this obviously doesn’t work.

You still need to edit the hosts file, located at /etc/hosts, but obviously there’s no nbtstat command to run afterwards. Depending on where you look on Google you’ll find a number of answers, from running niload to lookupd but none of those worked for me. Thankfully I found the answer – here it is.

Flushing DNS Cache:

sudo dscacheutil -flushcache

Obviously you’ll need the sudo part unless you’re running your shell as root … let’s not get into that, though. 🙂

If you want to make an alias to this command so you don’t need to type the whole thing every time, do this:

Flushing DNS Cache:

alias flushcache=’sudo dscacheutil -flushcache’