Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Anybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
Asked
Viewed
29k times
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.
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.
-
Click the + button to add a new shortcut
-
Select “Terminal.app” 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 -
Now ⌘W will not close your terminal windows.
7
You can set a prompt before closing in the preferences:
Terminal Preferences → Settings → Shell
4
I tried all of the above, and none worked for me.
What worked was changing the shortcut for the “Close” command.
6
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
3
A bit of an old question but in iTerm2 this helped me:
iTerm2 → Preferences → keys → Add key mapping: “command + w” => ignore
1
Goto Keyboard System Preferences and select “Keyboard Shortcuts”. Then choose Application Shortcuts from the left and click +. Choose “Terminal.app” 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.
For iterm, as @Shwaydogg mention:
For those using iTerm go to Prefrerences -> Profiles -> Session -> Prompt before closing!
Also worth mentioning BetterTouchTool (http://www.bettertouchtool.net/)
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
You must log in to answer this question.
Not the answer you’re looking for? Browse other questions tagged .
lang-bash