9

Is it possible to disable the cmd + q hotkey for Terminal on OSX? and if so then how?

3 Answers 3

16

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!

5
  • 6
    defaults write com.apple.Terminal NSUserKeyEquivalents -dict-add "Quit Terminal" nil removes the shortcut altogether.
    – Arjan
    Dec 15, 2010 at 20:06
  • @Arjan Is this documented somewhere?
    – Daniel Beck
    Dec 15, 2010 at 20:07
  • 1
    I found it here: oreillynet.com//cs/user/view/cs_msg/46459 (there's a link to the main article, but it's the user comment that I learned this from.)
    – Arjan
    Dec 15, 2010 at 20:10
  • For Option 1: you have to enter the menu name as you see it in your application. In my case, I want to deactivate Command-Q for a German Firefox. The entry is therefore Firefox beenden, which I have linked to Command-Shift-R. Oct 3, 2015 at 21:06
  • 1
    @Arjan 10 years later this is still working :) And this is awesome. I have just used this with UnityHub because I kept forgetting that there was an active download and quit it, and ruined my download. Just typed "defaults write com.unity3d.unityhub NSUserKeyEquivalents -dict-add "Quit UnityHub" nil" and completely disabled command-q. Mar 23, 2022 at 21:29
7

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.

1
  • Nice! Odd that things like ssh are listed as a default in "Prompt before closing".
    – Arjan
    Dec 15, 2010 at 22:42
2

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

1
  • This answer is under-rated!
    – akirekadu
    Mar 12, 2021 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.