Configuring the Alt Key for Command Line Navigation in iTerm2
I recently came across an excellent book called Effective Shell by David Kerr. I’m currently halfway through the book and have found the chapter Fly on the Command Line particularly useful. It describes shortcuts for navigating quickly on the command line. You can see the image below for a quick reference:

However, I encountered an issue when trying out this chapter on macOS with zsh in iTerm2. The problem was that the Alt key wasn’t working properly. After some research, I discovered that I needed to configure iTerm2 before it could properly process the Alt key. Here’s the fix:
- Open iTerm2 → go to the menu bar:
iTerm2
→Settings
(or pressCmd + ,
) - Go to the Profiles tab → select your profile (usually “Default”)
- Go to the Keys tab
- Look for the checkbox: “Left Option (⌥) Key acts as +Esc”
- Enable this option. This tells iTerm2 to send
Meta
(Alt) instead of special characters
- Enable this option. This tells iTerm2 to send
By following the steps above, you should be able to configure your Alt key to work like it would on Linux.