2

This is probably related to this question:

How do I do Home and End in iterm2?

but fiddling with the iTerm2 key mappings (both general and per-profile) to un-map option plus the left and right arrow keys still doesn't work right for me with zsh command line actions.

With Terminal.app, those option + arrow combinations go back and forward on the command line by word (space-separated blob basically).

I'd love to be able to do that with iTerm2, but despite my having asked for the mappings for the combinations to be removed they still don't work.

Ironically the main reason I installed iTerm2 was to be able to disable the (to me) insane behavior of command-p (print), which had wasted a bunch of my printer paper.

When I bring up Terminal.app, those key combinations work properly, so I think my zsh setup is correct.

5
  • 1
    Well, if the only reason to not use Terminal.app is because of that shortcut, override it with something else you'll never type. System Preferences >> Keyboard >> Shortcuts >> App Shortcuts , and add a shortcut for Terminal.app named "Print..." Jul 31 at 21:31
  • @MarcWilson I will give that a try, thank you
    – Pointy
    Jul 31 at 21:34
  • @MarcWilson unfortunately that doesn't seem to do anything. The Settings view shows the key binding, but Terminal still recognizes command-P as "Print...". The other one (command-opt-/) doesn't launch the Print dialog.
    – Pointy
    Jul 31 at 21:44
  • Works for me, as they say. The Shell menu in Terminal.app reflects what I override the shortcut with. Your menu text has to match EXACTLY, so since Terminal.app has "Print..." (Print-dot-dot-dot) , you need to have "Print..." in the shortcut. Jul 31 at 21:55
  • Yea I checked "Print..." and re-typed it.
    – Pointy
    Jul 31 at 22:15

1 Answer 1

2

You have to configure iTerm2 to send Esc-B and Esc-F to get the back/forward functionality you're looking for.

Go into Iterm2 Profiles and edit the profile you're interested in. Then, under the key mapping section, choose the "Option Right Arrow"

enter image description here

When you double click on it, you'll need to select the option "Send Escape Codes"

enter image description here

  • For the left arrow use "b"
  • For the right arrow use "f"

Match with Terminal

Here's a little hack you can do to match what you see from Terminal and apply it to iTerm2. Simply go into the key mapping preferences in Terminal (shown below) and select the item you want to copy over.

It will give you the code as \033b; the \033 is the Esc and b is, well, b. In iTerm2, it's asking for the code after Esc, so in this particular case, it just needs the b.

enter image description here

4
  • Does one have to configure this separately for EACH profile?? Aug 16 at 6:04
  • Yes, but you can create a master profile from which you can duplicate. In the Profiles tab, at the bottom, there's an "Other Actions" button where you can import/export profiles as well as duplicate existing profiles. This is how I keep profiles consistent across different Macs running different versions of iTerm2
    – Allan
    Aug 16 at 13:04
  • So to make it clear: If you set up a new Mac, you export all your profiles from the old one, and then import the back up in the new one? Aug 16 at 13:09
  • Generally yes. Sometimes, I don't want everything mirrored like that. That's where import/export comes in.
    – Allan
    Aug 16 at 13:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .