1 osx snippet

Setting up the cursor movement keys in iTerm2 on OSX

iTerm2 is a nice, customizable terminal emulator for OSX, but the typical cursor movement keys (such as ⌘← (Command-Left) for "move to beginning of line and ⌥→ (Option-Right) for "move forward one word") never seem to work for me out of the box.

Here's how to set them up (based on build 2.1.4):

1) Clear out any per-existing bindings for these short-cuts. There two different places to check--in the "global" keys and in the "profile" keys.

  • For the profile keys go to Preferences > Profiles > Keys and look for the ⌘←, ⌘→, ⌥← and ⌥→ shortcuts (and delete them if found.)
  • For the global keys go to Preferences > Keys and look for the symbols in (and remove them from) the "Global Shortcut Keys".

2) In either the profile or global shortcut settings (your choice) add the shortcuts back in, with the following bindings:

  • Use Send Escape Sequence f for "move forward one word". On OSX, I bind this to ⌥→ (Option-Right) as that seems to be the convention other apps follow.
  • Use Send Escape Sequence b for "move backward one word". On OSX, I bind this to ⌥← (Option-Left).
  • Use Send Hex Code 0x05 for "move to end of line". On OSX, I bind this to ⌘→ (Command-Right) as that seems to be the convention other apps follow.
  • Use Send Hex Code 0x01 for "move to beginning of line". On OSX, I bind this to ⌘← (Command-Left).

Now these keys should work the way your muscle memory (or at least my muscle memory) expects them to.

Published 14 Jan 2016
Tagged osx and iterm2.

 

This page was generated at 4:16 PM on 26 Feb 2018.
Copyright © 1999 - 2018 Rodney Waldhoff.