If you aren't totally set on using Terminal, I believe that iTerm2 has a setting to just use one of the option keys as meta. If you are, is there a setting to maybe use the Esc key as meta? I know that it's more convenient to use the option key, but the Esc key might be easier to set.
In general, Mac applications that are expecting text input from the keyboard do not handle C-S combinations or C-digit combinations. Programs that work with control-shift combos (like anything running under X11) do so by handling key events as events, not character input. This is how they can differentiate between Tab and Ctrl-i, which both generate the same ASCII character. (You can read in detail how Lion (really Cocoa) handles key events if you really want to know.)
Historically (back in the Teletype days), there were only uppercase letters on the keyboard, and there were no caret (^) or underscore (_) characters on the keyboard (instead there were up-arrow and back-arrow). The shift key worked by toggling the 16's bit and the control key worked by zeroing the 64's bit of the 7-bit ASCII codes the keyboard produced.
What this means is that the control key had no effect for the 32 characters on the keyboard that already had their 64's bit set to zero (most of the non-alphabetic characters, including digits), and since the teletype was purposefully limited to upper-case letters only, the shift key had no effect on most of the alphabetic characters (and where it did have an effect, it produced a special character like @).
Additional weirdness was added in the migration to supporting lower-case text, as the control key combos were all typed without using the shift key but now the letter typed without using the shift key had changed, so the decision was to map control-lower-case to what had been control-upper-case. But then what do you do with control-shift?
For a while the problem was handled by having the control key also zero out the 32's bit, which is what differentiated lower case letters from upper case letters. But eventually ASCII was replaced with Unicode and those kinds of duplicate key assignments were too much of a waste of keyboard space to be allowed to continue, so they got different mappings, and on the standard Mac US keyboard most C-S combos are unassigned.
So what you have run into is the legacy support for keyboard input running back to Teletype days. The characters Terminal (and other OS X apps) do not support are characters you could not type on the Teletype keyboard. As evidence of this, note that C-S-2 (C-@), C-S-6 (C-^), and C-S-- (C-_) all work, because those keys have been re-mapped since the ASR-33, where S-2 was " (and @ was S-P), S-6 was &, and S-- was =, but in general control-shift combos do not produce characters of any kind.
Best Answer
I have similar desires to yours. I solved it using a system-level modifier-key re-bind.
(Of course, this is a mess; but I find it worth it to maintain my MacVim-trained hybrid of OS-wide controls (save, new, copy, paste) within command-line
vim
s.)Here's how I did it:
Enable “Command_L to Control_L (only in Terminal)”:
Map ⌃-prefixed controls matching whichever MacVim commands you're most used-to in command-line
vim
. For instance, to support ⌘S,Restore expected ⌘-sequences for Terminal.app itself, by special-casing them in System Preferences. For instance, if you want ⌘N to still control Terminal tabs, instead of mapping it to
vim
files, try:Now, anything you don't add in this list, will be passed through verbatim to command-line
vim
(and, of course, any other command-line program you use.)Caveats
This approach has several further subtle downsides, that I want to hilight for anyone considering taking it (as I do):
stty -ixon
in your shell's startup-script, as ⌃Q is consumed by default to preform an archaic shell-control function (one with no modern usage.)Alternative ⌘W behaviour
In addition to the above, I decided to further override ⌘W as a universal ‘close this’ key, applicable to multiple applications.
Instead of mapping ⌘W to ‘Close Tab,’ as above; I personally map that to ⇧⌘W (to retain “immediately close this tab” semantics.) Then, in any given program, I map ⌃W to some sort of close-save-quit functionality.
For instance, in my
.vimrc
:… or my
.zshrc
:With those two snippets in place, and your Terminal configured to ‘Close if shell exits cleanly,’ a series of ⌘Ws will first quit vim, and then close the shell entirely.
In addition, now additional on-exit functionality of programs can be preserved: for instance,
vim
will ask before quitting if files are unsaved (just like MacVim); andzsh
will ask before quitting if there are background jobs.Postscript: Not directly related to your question; but you should also check out ‘Ubiquitous Vim Mode’ in Karabiner. It's “a bit much” for me to use everyday, but it's a very cool idea, and surprisingly-well implemented.