Automatically quitting Terminal.app windows

Software

Quite often I find myself using a particular application for a long time, and only realising that something I'm doing can be done a lot simpler, or even automatically. A quick smack on the head with the palm of my hand and a few shots of espresso is generally called for, followed by implementing the previously unused feature.

In this case it's a feature of the improved and vastly more usable new Terminal.app bundled with Mac OS X Leopard. In earlier versions of OS X I used mrxvt in X11 for most of my shell goodness; a less elegant alternative to iTerm but one which I found more reliable. Unlike previous Terminal.app versions, mrxvt had a tabbed interface, and exited automatically whenever the process you were working on finished cleanly. I knew Terminal.app in Leopard had the former feature but not the latter… despite it being right under my nose the whole time.

The Leopard Terminal indicating a process has been completed, with the window still open
The Leopard Terminal indicating a process has been completed, with the window still open

To get the Leopard Terminal.app to automatically close its window when the process you're working on finishes cleanly:

  1. Hit [Command]+[,] to bring up the Preferences screen
  2. Click Settings, then click the theme you want to change.
  3. Click Shell and choose Close if the shell exited cleanly from the When the shell exits: listbox.

Now whenever a process you've initiated finishes, or if you type exit in your shell, the window closes automatically. When you have tens of tabs open at once, this saves a LOT of time!

The Leopard Terminal Preferences window
The Leopard Terminal Preferences window showing changed setting

Author bio and support

Me!

Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.