---
title: Launching your entire Dock at once
date: 2012-08-03 19:51
slug: launching-your-entire-dock-at-once
categories:
- Code
tags:
- macos
- scripting
- terminal
---

![Dock Dock](/uploads/2012/08/DockDock.jpg "That's a pretty Dock. It's a shame you hide it all the time.")

Get your nerd hat on.

I keep my Dock very trim. The only apps that have a permanent home there are apps that I either *have* to have running all day, or apps that I *choose* to have running all day. However, I don't make them launch items. Booting up can be slow enough without trying to launch five heavy apps at the same time that everything else is loading.

More often than not, I need them all at once (Adium, Skype, Twitter, Mail, Sublime Text, iTerm 2 right now, if you're wondering). I've been thinking for a while that I should write a quick AppleScript to just launch them all at once. Then I thought about how much my app selection changes over time, and the minutes of my life I would lose maintaining such a script.

Then, I realized that the Dock itself could be a dynamic launch group. With the way I use my Dock, it makes perfect sense to just launch whatever is in the Dock at the time that hasn't already launched. The Dock happens to store a list of all of its permanent residents in a the defaults system, and you can read them out and run the ever handy `open` command on the list. It's so easy it's a one-liner that can be scripted into a LaunchBar or Alfred command, run with FastScripts at the push of a button or even [wrapped up](http://sveinbjorn.org/platypus) and made into a Desktop button[^button].  Here's the script, broken out for readability:

	for app in $(defaults read com.apple.dock persistent-apps|\
	grep bundle-identifier | awk '{print $3}'| tr -d '";'); do 
		open -bg $app
	done
	
`defaults` reads out the array stored in the `persistent-apps` key, `grep` pulls out just the lines with the bundle ids, `awk` extracts the ids and `tr` cleans out semicolons and quotes. The result of that part looks like this (for me...):

	com.googlecode.iterm2
	com.adiumx.adiumx
	com.skype.skype
	com.twitter.twitter-mac
	com.google.chrome
	com.apple.mail
	
Then the shell script just passes one line at a time to the OS X-specific `open` command. The `-b` option tells it I'm passing a bundle id, and the -g launches the apps in the background so I can keep working on whatever I might be doing without interruption. There's also a `-j` option to launch the apps completely hidden.

**Update:** [Keith Smiley](https://twitter.com/SmileyKeith/statuses/245494154703020032) offers a [slightly modified version](https://gist.github.com/3697921) that handles some edge cases.

As a side note, one other `open` command option of interest is `-F`, for opening applications "fresh"; without restoring their windows. It doesn't work with every app (Sublime Text 2 is incorrigible in that regard), but it's handy most of the time. I don't recall seeing it in Lion, but I could be wrong.

[^button]: That's definitely the lack of sleep talking.

---

Brett is a writer and developer living in Minnesota, USA. You can follow him as ttscoff. This content is supported by readers like you. [More about Brett](https://brettterpstra.com/contact.md), including social links.

Copyright © 2026 Brett Terpstra. All rights reserved.
