---
title: Quickly restarting apps with LaunchBar (and friends)
date: 2012-07-27 16:00
slug: quickly-restarting-apps-with-launchbar-and-friends
categories:
- Code
tags:
- applescript
- macos
- scripting
---

<img src="/uploads/2012/07/powerbutton200.jpg" alt="power button" title="power button" width="200" height="180" class="alignright size-full wp-image-4501" />I've been using this little trick frequently for a while now. I doubt "normal" people ever need to frequently restart apps, but when I start working on [keybindings](http://brettterpstra.com/tag/keybindings/) and other things that require fresh starts to take effect, it's nice to be able to do so with a couple of keystrokes.

The AppleScript is far from brilliant (and utterly simple), but it looks like this:

```applescript
tell application "System Events"
	set _app to the name of every process whose frontmost is true
end tell

tell application named _app to quit
delay 2 -- Props to Dr. Drang
tell application named _app to activate

-- optionally, if the apps you want to terminate don't respond well to `quit`
-- do shell script "killall \"" & _app & "\" && open -a \"" & _app & "\""
```

Open it in AppleScript Editor and save it as "Restart App.scpt".

It figures out which app is in the foreground, quits it nicely with AppleScript and then uses the Unix `open` command to relaunch the app. If the apps you're restarting aren't responding quickly enough to the quit command, consider replacing the `tell/quit` and `do shell script` lines with the commented line at the end. That'll knock 'em down. <del datetime="2012-07-27T21:34:00+00:00">Also, I played for a little while with using AppleScript to re-open the app, but it got frustrating enough that I skipped to just using `open -a`. There's really no consequence I know of to that method, so why lose hair?</del> <ins datetime="2012-07-27T21:34:00+00:00">[Dr. Drang solved this one for me](https://twitter.com/drdrang/status/228964608386412544), just needed a little delay between the commands. Increase the delay if needed, the argument is an integer denoting seconds to pause.</ins>

You can launch this script from any launcher that doesn't take the foreground (FastScripts, LaunchBar, Alfred, QuickSilver, etc.). In most of the aforementioned launchers, you can just pop them up, type `ra` and hit enter and your app flashes out and back in. Even if you don't have an immediate need for this, you can have a lot of fun setting it up to run at random intervals on friend's machines. Thanks to Autosave it's practically harmless[^fn1].

[^fn1]: It's not. That was my bad sense of humor talking. Do not do it. Why are you poking around on your friend's machine anyway? Seems like you'd have better things to do with your time.

---

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.
