Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Disable Command-Q for quitting applications System
Ever hit Command-Q instead of Command-W and lost all of your open web pages in Safari? It happens to me exactly one time to often. So I remembered an old trick to map Command-Q out of the way. Just go to Terminal and enter:
defaults write NSGlobalDomain NSUserKeyEquivalents
   '{"Quit Safari" = "@Q"; "Quit Mail" = "@Q";}'
[That should be one long line with a space after the NSUserKeyEquivalents word]

From now on, Command-Q will "beep" and only Command-Shift-Q will quit the application. A very similar hint tells you how to handle keys like Command-Option-.

You may also use Safari's defaults to change this, but I prefer this "global" way to have these special keys all together in one place. Unfortunately the menu is NOT named simply "Quit" but "Quit Safari," e.g., so you have to enter one extra entry for all apps in question.
    •    
  • Currently 2.91 / 5
  You rated: 1 / 5 (11 votes cast)
 
[46,706 views]  

Disable Command-Q for quitting applications | 21 comments | Create New Account
Click here to return to the 'Disable Command-Q for quitting applications' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Disable Command-Q for quitting applications
Authored by: Johnny_B on May 05, '03 11:50:39AM

I love you man, works great. If had got one cent for everytime I
have quited Safari or other tabbed browsers using cmd+w as
closing tab button I would have been milionar !!!



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: Mac112 on May 06, '03 04:19:10AM

Brilliant! I've really missed this for a long time.



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: GaelicWizard on May 08, '03 12:53:57PM
Here's whay mine says:
defaults write NSGlobalDomain NSUserKeyEquivalents '{"Quit Safari" = "@Q"; "Preferences..." = "@;";}'
I don't need the extra option to quit Mail.app, but i have been quite frustrated by the different key-combos for the preferences window. W/ this, it is now a universal for ALL apps that have a "Preferences..." option under the {insertAppNameHere} menu. Wonderful! I'm about to submit this as a real hint, wish me luck! :-D

---
Pell

[ Reply to This | # ]

Disable Command-Q for quitting applications
Authored by: toothfish on May 09, '03 11:13:34PM
while i appreciate this, it'd be much more useful to enbale command-H to hide applications in applications that don't support it (ahem... indesign). is there any way to do this?

[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: zpjet on Jan 30, '05 03:10:20AM

i guess you can just go to edit > keyboard shortcuts and remove or change the command's (view > hide frame edges) shortcut. in photoshop, too. but actually, i got so much used to those shortcuts (hiding selection in photoshop already twelve years) that i would hide it using menu or alt-click finder instead...



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: zpjet on Jan 30, '05 03:31:08AM

i guess you can just go to edit > keyboard shortcuts and remove or change the command's (view > hide frame edges) shortcut. in photoshop, too. but actually, i got so much used to those shortcuts (hiding selection in photoshop already twelve years) that i would hide it using menu or alt-click finder or another app instead...



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: greg418 on Feb 11, '04 05:55:10AM
I would instead set the shortcut for "Preferences" to the new 'Apple-way' cmd-, as cmd-; is used in Cocoa apps to invoke the spell checker (the one that sits in the Edit menu...).

just in case though, I would set it app-by-app to avoid the possibility of "overriding" a new application's default cmd-, action, which could be unrelated to opening the prefs window...

best

greg

---
loops of fury

[ Reply to This | # ]

Error Message
Authored by: klanda on Feb 11, '04 11:10:45AM
Hey. I tried to modify the script so that it would apply only to Safari. I entered it as follows:
defaults write NSGlobalDomain NSUserKeyEquivalents  '{"Quit Safari" = "@Q"}'
Unfortunately I got the following error messages.

2004-02-11 11:02:50.798 defaults[1062] CFLog (0): CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary.
2004-02-11 11:02:50.820 defaults[1062] CFLog (0): CFPropertyListCreateFromXMLData(): The file name for this data might be (or it might not): file://localhost/usr/share/zoneinfo/Canada/Eastern
2004-02-11 11:02:50.909 defaults[1062] Could not parse: {"Quit Safari" = "@Q"}.  Try single-quoting it.
Any help on what I did wrong? Thanks, Ken

---
-------
.sig

[ Reply to This | # ]

Error Message
Authored by: noj on Feb 26, '04 04:57:22PM

judging from the error:
2004-02-11 11:02:50.798 defaults[1062] CFLog (0): CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary.


I would put a semicolon after "@Q" so that you have:
'{"Quit Safari" = "@Q";}'



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: marklar on Jun 11, '05 08:28:59PM

Does this work with Tiger?

I am most interested in disabling this in games, specifically UT 04...can't tell you how many times I'm in contact, go to jump (command key) and call for a weapon switch (the Q is mapped to shield gun) and bye bye game...

Any help would be greatly appreciated.

Thanks



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: calvarez on Nov 04, '05 01:03:15PM

You can change/disable keys for any app right in the GUI. Just go to the Keyboard/Mouse prefs pane, and add an item under the Application shortcuts. Add an item for cmd-q and make the menu title anything that doesn't actually exist (I put in the word "Nothing" just to remember what it is later). Then cmd-q will no longer work in that app. You can add something else for quit, or just use the menu.

For some reason this doesn't work under "All applications."



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: cssbz on Nov 22, '05 09:04:42AM

Sounds good, but it doesn't work for me on 10.4.3. I can see "Nothing" listed as a description for command-Q for Safari.app in Keyboard Shortcuts, but pressing command-Q still quits Safari. :(



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: jacobolus on Feb 01, '06 09:44:51AM

Yes it does work, but only for cocoa apps. I'm not sure about those games...



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: resuna on Mar 30, '06 12:02:24PM
This should do the trick for all currently installed applications. :)
find / -name '*.app' | sed -e 's,.*/,,' -e 's/\.app$//' -e 's/.*/"Quit &" = "@Q";/' | tr '[\n]' '[ ]' | sed "s/.*/defaults write NSGlobalDomain NSUserKeyEquivalents '{&}'/" | sh
But I haven't tested it, so for god's sake don't use this unless you understand what it does well enough to debug it yourself. :)

[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: waynerrr on Oct 26, '09 04:49:01AM

i decided to bring alive this old post to today (November 2009 almost)

I really use a lot of keyboard shortcuts

But, I really dislike the Command Q (apple key + Q) command because I was sick to death of "quitting without warning" applications by accidently hitting the wrong shortcut (e..g I use command+A (select all) often) and this is so close to the "quit" shortcut

anyhow I'm on Leopard & i didnt fancy risking commands in the terminal so i did this
"system pref" keyboard & mouse" I changed "show help menu" to command+Q (you can change anther one if you dont fancy altering this one)

thus the result is I've completely disabled the ability to quit Apps


P.S. I think command + Q to quit without warning is a horrible shortcut and one that causes me regular inconvenience.



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: glenno on Nov 19, '09 08:34:55PM

You rock! THANK YOU for posting this.

I sure wish these universal shortcuts could be re-assigned within applications (I like Cmd-Q to do something else in Word, e.g.), but this is a great fix for the bigger QUIT problem on Macs!

ETA: Oh, looks like Calvarez may have posted about that above.

Edited on Nov 19, '09 08:37:26PM by glenno



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: glenno on Nov 20, '09 06:07:29PM

Oh wait -- so I still can't assign Command-Q to a keyboard shortcut in Word. Drat. I've used such a shortcut for a decade on the PC, is there ANY way to do this? Even if I assign it in System Prefs it doesn't work, the command doesn't have a name that's recognized I guess.



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: yabosid on Jul 08, '10 06:11:06PM

In order to do the same for Google Chrome open up terminal and type:

defaults write com.google.Chrome NSUserKeyEquivalents '{"Quit Google Chrome"="@$Q";}'



[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: pax on Dec 02, '10 07:13:12AM
thanks, it worked for me. seems though that Chrome might soon get a proper fix for this.

[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: palahala on Dec 15, '10 12:50:42PM

I don't understand how "Quit Safari" = "@Q" would disable Command-Q, as @Q actually is Command-Q. So I guess the web site software left out the dollar character? Otherwise, I assume earlier versions of OS X interpreted an uppercase Q as being Shift-q? Anyway: I think in Snow Leopard one would need: "Quit Safari" = "@$Q".

Also, there's another way to get it done, by overriding the existing shortcut to be nil:

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

[ Reply to This | # ]
Disable Command-Q for quitting applications
Authored by: BCKJ on Jan 28, '11 12:32:39PM

eeeer sorry but does anyone know how to re activate the command Q to quit things? sorry



[ Reply to This | # ]