Considered as the best terminal emulator on OS X platform, iTerm 2 does offer plenty of options one could tweak to achieve the fully-customized
version to suit each one.
I want to use cmd as meta, for I work with tmux intensively, but losing cmd+tab is not an option. Fortunately, there’s a section titled “Swap
Cmd and Option” in iTerm 2 documentation. The main idea is to swap cmd with alt (aka
option), and add one exception to bypass the remapping for cmd+tab key combination.
Reprint the pertinent content here:
Swap Cmd and Option
iTerm2 allows you to remap modifiers. You have separate control over left and right command and option keys. One common need is to exchange cmd and
option. To do this, go to Preferences > Keys. Set Left option key to Left command key and Left command key to Left option key (and do the same for
Right command and Right option if you please). You can add exceptions if you don’t want certain combinations to be remapped (for example, cmd-tab)
by adding a new global shortcut with the action “Do Not Remap” and the keystroke of the (unremapped) key you wish to keep unaffected by modifier
remapping.
-- waiting for network set max to10 repeatwith i from1to max try do shell script"ping -o www.google.com" exitrepeat onerror delay6 if i = max then display dialog"Network down." errornumber-128 endif endtry endrepeat
tellapplication"iTerm" quit delay0.1 endtell
-- switch to Desktop 2 tellapplication"System Events" do shell script"/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control" delay0.5 tellapplication"System Events"to click (first button whose value of attribute "AXDescription"is"exit to Desktop 2") oflist1of group 1of process "Dock" endtell
tell i term application"System Events" keystroke space using option down endtell
tellthe current terminal writethe current session text"htop"
launch session "Guake" writethe current session text"nettop" writethe current session text"d"without newline writethe current session text"c"without newline
launch session "Guake" writethe current session text"cd Documents"
launch session "Guake" writethe current session text"vm; hg pull -u"
launch session "Guake" select first session endtell
tell i term application"System Events" keystroke space using option down endtell
delay1
set myterm to (make new terminal) tell myterm terminate the current session launch session "Default" writethe current session text"phd" writethe current session text"ta" endtell endtell
-- switch to Desktop 1 tellapplication"System Events" do shell script"/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control" delay0.5 tellapplication"System Events"to click (first button whose value of attribute "AXDescription"is"exit to Desktop 1") oflist1of group 1of process "Dock" endtell