How to disable command + q for Terminal on OSX

You have two options:

  1. Assign a different shortcut that's not as prone to be hit accidentally.
  2. delete the existing shortcut

Option 1 can be accomplished in System Preferences » Keyboard » Keyboard Shortcuts » Application Shortcuts. As an example how option 1 looks like: alt text

alt text


Option 2 (removing the keyboard shortcut) requires the Terminal. Simply enter:

defaults write com.apple.Terminal NSUserKeyEquivalents -dict-add "Quit Terminal" nil

Thanks @Arjan!


If you want to disable command-q because you're closing command-line programs accidentally, you can get Terminal to warn you before closing. Go into the Settings section of the Terminal -> Preferences... menu item and select the set up you use ("Basic" is the default). Then, under the shell tab is "Prompt before closing" - if you set this to "always", you'll be asked for confirmation if you hit command-q by accident. Alternatively, you can set a list of programs that won't interrupt you (mostly remote shells by default), while others will still cause a prompt.


I reccomend overwriting a keyboard shortcut like the show/hide the panel (or anything that's not as "painfull" as terminating applications). Then nothing serious happens when you accidentally click the command+Q combo.

How?

  1. go the apple icon
  2. then "System preferences..."
  3. then "Keyboard"
  4. then "shortcuts"
  5. and then "Launchpad & Dock"
  6. Change the shortcut for "Turn Dock hiding On/Off" to command+Q

This screenshot shows what to do:

enter image description here