I detailed the
open command in the last Shell Tricks post, so I thought I’d go over some tricks for doing the opposite next: closing and quitting apps.
The first thing I’ll mention is a shell script from Jon Stovell called
quit. You can download it from his freeware page. It uses AppleScript (with some great logic) to “nicely” quit any application. I’ve mentioned it before, as well as tricks for adding Bash completion to it.
First, you need the
fp (find processes) command, which gives you a case-insensitive, partial title search for running processes (you can add both of these to your
And here’s the revised
fk command. Give it part of a process or app name and it will give you a menu of all matches (case-insensitive). Cancel the menu with “q” or enter a number. If the process is a Mac app, it will use quit, otherwise it will
kill the specific process chosen.
Note that you need the quit script in /usr/local/bin (or edit the
fk function to match your own location).
Now you have the counterpart(s) to OS X’s
open command. Enjoy!
Ryan Irelan has produced a series of shell trick videos based on BrettTerpstra.com posts. Readers can get 10% off using the coupon code