iTerm2 is a replacement for the default Terminal application on MacOS. It has many more handy features than Terminal, is free to download and is also open source π.
However, on initial install, you canβt use the Option or Alt key (the one that looks like this: β₯
) as you would in other applications: it's not possible skip or jump over words by pressing Alt and the left or right keys. Instead you see sequences like [D
or [C
:
This can be changed by tweaking a couple of settings, which I'll explain below.
Note: I refer to the "Alt" key throughout this post, as this is the text written on the key of my old 2013 MacBook Pro keyboard, but this is normally called the "Option" key in MacOS.
Open the "Preferences" menu: either find it in the "iTerm2" dropdown menu along the top of the screen or press the Command and comma keys. β + ,
Choose the "Profiles" menu.
Select the "Keys" tab.
Within the "Key Mappings" pane, find the mapping for the Alt and left keys, which will look like this: β₯β
. Double click it.
Change the action from "Send Hex Code" to "Send Escape Sequence" (you might have to scroll a bit to find this).
In the "Esc +" field, type lowercase "b" and click "OK".
Open the same context menu for Alt plus right β₯β
and again change the action to "Send Escape Sequence".
This time, in the "Esc +" field, type lowercase "f". Click "OK".
Close the Preferences menu. The changes take effect immediately. When you press β₯ + β or β, the cursor will jump over entire words as it does on other applications. You can now navigate the command line with more precision and speed.
Bonus shortcuts
Control + e will move the cursor to the end of the line.
Control + a will move the cursor to the beginning of the line.
Top comments (2)
yep, Thanks so much
Thanks !