Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to disable Command+W in the terminal?

On several occasions I have accidentally closed a terminal window containing important information when I meant to close a Safari tab and did not realize that the terminal was the active window.

share|improve this question
up vote 38 down vote accepted

To disable W in Terminal, do the following:

  • From the  menu in the top left corner of the screen, select System Preferences. Click on Keyboard then Keyboard Shortcuts then Application Shortcuts. enter image description here

  • Click the + button to add a new shortcut

  • Select "" for the application, and for the command, type Close Window (this is case sensitive). In the shortcut box, give it a different shortcut, like ControlW enter image description here

  • Now W will not close your terminal windows.

share|improve this answer
I mis-spoke in my question. I actually meant to prevent closing a tab, but your answer still works well with the slight change of "Close Window" to "Close Tab". BTW, thanks for the VERY complete answer. – Ralph Mar 19 '12 at 13:05
@Daniel: Nice screenshots! May I ask which program you used to take them? Or did you change your desktop background to all-white? – Roy Tinker Mar 19 '12 at 16:16
The program is called "Mac OS X" :-) Command-shift-4, spacebar, click in the window. – Daniel Mar 19 '12 at 16:20

You can set a prompt before closing in the preferences:

Terminal Preferences → Settings → Shell

enter image description here

share|improve this answer
Answers crossed paths. This is a good one too. – Daniel Mar 19 '12 at 12:44
I think this is the best solution for this particular use case. Disabling standard shortcuts makes me feel icky and would get frustrating when muscle-memory kicks in when I want to close a terminal tab/window. – ghoppe Mar 19 '12 at 17:58
-1: OP asked a very specific question that could easily be modified for various applications. This is a specific answer which does not answer the question. – Max Ried Mar 10 '14 at 20:14
For those using iTerm go to Prefrerences -> Profiles -> Session -> Prompt before closing! Make sure you are on the correct profile (your default one has the star!)… – Shwaydogg Aug 30 '14 at 19:16

Goto Keyboard System Preferences and select "Keyboard Shortcuts". Then choose Application Shortcuts from the left and click +. Choose "" and enter a menu item that is not that critical. I chose "Bring All to Front". Then click into Keyboard Shortcut and hit CMD+W. Click OK.

Using this technique have have successfully redirected the CMD+W shortcut in Terminal.

share|improve this answer

I tried all of the above, and none worked for me.

What worked was changing the shortcut for the "Close" command.

enter image description here

share|improve this answer
Same here. "Close" worked for me but "Close Windows" did not. – imagineerThis Oct 31 '13 at 18:42
Ian, it says "iterm" not "TERMINAL" – GummyArgyle Mar 7 '14 at 1:13
@LM126, yep, my example is using iTerm2, so not sure what your on about? – Ian Vaughan Mar 7 '14 at 9:38

I propose this:

In iTerm: Open Preferences>Keys At the bottom of "Global Shortcut Keys" click "+", then type Cmd-W and leave the default Action "Ignore".

  • no need to manipulate global settings
  • no need to confirm conscious closing
share|improve this answer
This is the only effective solution for me on Mac OS 10.10 – bitcycle May 26 '15 at 14:47

Also worth mentioning BetterTouchTool (

I wanted to have both W & C both perform Copy (muscle memory, don't ask). The native method only allows you one key per command, with BTT I was able to have both keys mapped to same command, while also avoid the undesired Close WIndow behaviour

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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