I don’t just use the command-line, I live on it.
With doing some much on the CLI, I always have the Terminal app running, regardless of my host operating system.
Sadly, on macOS, I do find myself accidentally hitting Command+Q from time to time, which abruptly bails me out of the Terminal.
While I am usually running a
tmux session (or a few), this isn’t the biggest
inconvenience in the world, but I do find it frustrating enough that I sought
out to figure out how to ax that shortcut entirely.
Before I proceed with talking about how to disable the shortcut, keep in mind that I do have “Ask before closing” set to something other than “Always”.
Obviously having that turned on would keep me from accidentally closing windows, but it also would mean that I’d be prompted even when I’m closing tabs, which I do regularly, and would get pretty old quick.
That all being said, there is a quick and easy way to remove the shortcut (or change it to something else, if that’s your thing). From the terminal, simply run:
defaults write com.apple.Terminal NSUserKeyEquivalents -dict-add "Quit Terminal" nil
And boom, Command+Q will cease to work within the Terminal app.
Regretting the decision? You can undo it running this (note
defaults write com.apple.Terminal NSUserKeyEquivalents -dict-add "Quit Terminal" "@Q"