There are a lot of tutorials for mapping the Option key (⌥) to Meta in iTerm, e.g. here, here and here to enable readline navigation and editing (M-b to move the cursor back a word, etc.).
What I'm looking for is doing the same but with the Command key ⌘. This is possible to an extent by first setting ⌥ to Esc+ and then mapping left ⌘ to left ⌥ and vice versa. Both are supported by iTerm2 out of the box (version 3.4).
The drawback of this is that now
- you can't use ⌘-TAB to toggle/cycle OS applications anymore (you have to use ⌥-TAB)
- with ⌥-TAB, toggling applications works but you can't hold ⌥ and cycle through open applications with TAB anymore
Emacs on macOS is somehow capable of supporting both readline shortcuts with ⌘ and normal ⌘-TAB behavior.
I've looked at Karabiner Elements but I haven't been able to configure it to do what I want.