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.

§Auto start with specific tabs/commands

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
-- waiting for network
set max to 10
repeat with i from 1 to max
try
do shell script "ping -o www.google.com"
exit repeat
on error
delay 6
if i = max then
display dialog "Network down."
error number -128
end if
end try
end repeat

tell application "iTerm"
quit
delay 0.1
end tell

-- switch to Desktop 2
tell application "System Events"
do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control"
delay 0.5
tell application "System Events" to click (first button whose value of attribute "AXDescription" is "exit to Desktop 2") of list 1 of group 1 of process "Dock"
end tell

tell application "iTerm"
activate
terminate the first session of first terminal

tell i term application "System Events"
keystroke space using option down
end tell

tell the current terminal
write the current session text "htop"

launch session "Guake"
write the current session text "nettop"
write the current session text "d" without newline
write the current session text "c" without newline

launch session "Guake"
write the current session text "cd Documents"

launch session "Guake"
write the current session text "vm; hg pull -u"

launch session "Guake"
select first session
end tell

tell i term application "System Events"
keystroke space using option down
end tell

delay 1

set myterm to (make new terminal)
tell myterm
terminate the current session
launch session "Default"
write the current session text "phd"
write the current session text "ta"
end tell
end tell

-- switch to Desktop 1
tell application "System Events"
do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control"
delay 0.5
tell application "System Events" to click (first button whose value of attribute "AXDescription" is "exit to Desktop 1") of list 1 of group 1 of process "Dock"
end tell