7

In iTerm2, can I map the left ⌘ Command key to the left ^ Control key and still map the system ⌘ Command ⇨Tab to still switch to all other windows?

I've use three different OS's (Ubuntu, macOS and Windows) regular and my subconscious is constantly wanting to switch windows using ⌥ Option⇨Tab.

2 Answers 2

8

While not answering the question I have discovered the following work around in the meantime for my most commonly used terminal "control+" inputs:

  • Ctrl+C - clear terminal line
  • Ctrl+R - reverse search

Set the remap modifiers in iTerm to default:

Remap modifiers in iTerm

Set the keybindings for Command+R, etc. to "Send Hex codes:" and enter the hex codes from http://ascii-table.com/control-chars.php as follows:

enter image description here

And viola it works for Command+R = Ctrl+R as required....to do the entire alphabet would require mapping multiple hex codes

1
  • How do you copy text from your terminal?
    – gogaz
    Commented Jul 21, 2023 at 11:59
5

Yes, it can be set in iTerm's Preferences → Keys → Remap Modifiers

Keys Remap Modifier

Next, in the same Preferences Pane, select Key Bindings Tab.

From there, you will see all the currently defined key bindings. If Control-Tab isn't defined you can create a new one, however this is a clean install and this is what's shown by default.

iTerm Key Bindings Tab

Double click on the "Action" description to modify the behavior.

It will bring up a (long) list of actions you can assign to the keybinding. (I selected "Cycle Tabs Forward")

iTerm Key Bindings Sub Menu

This will configure iTerm to accept the left ⌘ Command as ^ Control and is limited to iTerm only. ⌘ Command ⇨Tab still works, but within iTerm you must use the right ⌘ Command. Outside of iTerm, everything will function as normal.

If you're using Catalina, you will have to give Accessibility permissions to iTerm under System Settings → Security & Privacy → Privacy Tab → Accessibility if you haven't already done so.

6
  • @TimWiel - take a look at this question/answer: apple.stackexchange.com/q/283252/119271
    – Allan
    Commented Apr 18, 2020 at 22:56
  • Thanks @Allan I have done this however unfortunately your answer is responding to half the question sorry. Because the left command is now mapped to Control the standard system command of Command+Tab still doesn't work as expected because it is now sending Control+Tab to iTerm so doesn't switch windows. I suspect I need to map the Control+Tab keybinding to Command+Tab and it might work - anywhere I can do this??
    – Tim Wiel
    Commented Apr 18, 2020 at 22:57
  • The apple.stackexchange.com/q/283252/119271 link seems to be system wide remap - not just for iTerm - I still want left command to remain as is in every other application except iTerm - thanks!
    – Tim Wiel
    Commented Apr 18, 2020 at 22:59
  • Do you want Control-Tab to go through the tabs within iTerm?
    – Allan
    Commented Apr 18, 2020 at 23:06
  • So to clarify I have mapped, in iTerm, the command key to control and mapped the control key to left command. Therefore to go from iTerm to Google Chrome I need to push control+tab but to go back to iTerm from Google Chome I need to push command+tab (which is mac system default). However I want I really want is that command+tab in iterm switches to Google Chome but yet command+c or command+r (and so on) is still be mapped to control+c or control+r (and so on)....
    – Tim Wiel
    Commented Apr 19, 2020 at 4:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .