# Linux-like key binding in iTerm 2

I work regularly on both Linux and Mac. When I work in terminal on Linux, I use the Alt key very often. Alt is the prefix of many terminal shortcuts and I also use the Alt key in tmux to switch between panes within a window. This key, however, behaves differently on Mac. In this post, I will describe how to have Linux-like key binding in iTerm 2 for the Alt key.

## iTerm 2 settings

You need to change the following settings in iTerm 2.

• Preferences -> Profiles -> Keys -> Left option key as +Esc
• Preferences -> Keys -> Remap modifier key -> Swap left option and left command
• Preferences -> Keys -> Navigation shortcut -> Option for switching tabs

The first change makes your left option key behave like the meta key instead of a special key in macOS that outputs special characters when followed by letters. The second change swaps left option and left command, this is not a must but it aligns the position of Alt with normal Windows/Linux keyboards. The last change is to use option for switching tabs so that you could still use the actual command key for switching tabs, which I’m so used to personally.

Overall, these changes has the following effects

• command key works like Alt key in Linux
• option key works as command key

## Conclusion

This is not really perfect, as now you have to use option as the command key. This mean you need to use option + v for paste instead of command + v. However, being able to use command as Alt is more important to me so personally I’m OK with the changes I made.