Making Alt key work in ITerm on Mac
Making the Alt Key Work in iTerm2
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 first install, you canāt use the Option or Alt key (this key: ā„
)
as you would in other applications: you canāt skip or jump over words
by pressing Alt and the left or right keys. Instead you see sequences
like [D
or [C
:
With a little config, you can change this behaviour, which Iāll explain below.
Note: I refer to the āAltā key throughout this post, which is the text written on 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 Cmd 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 menu and begin using the Alt and the left/right arrows immediately. The cursor will now ājumpā over entire words as it does on other applications. Your command line navigation will now be faster and more precise.
Comments
Post a Comment