1

I've set up my bash in iTerm2 on Mac so that Option+Left goes backward a word, and Option+Right goes forward a word. I've done this to have a similar setup as on my Linux machine.

However, sometimes the setup stops working, and when I press Option+Left, the cursor doesn't jump a word backwards, but adds the string ;9D to the command line input. Option+Right then adds ;9C.

When open a new terminal, Option+Left/Right work correctly, only sometimes this incorrect behavior occurs. I have not yet figured out what causes this. Typing reset does not fix the issue, re-loading my bash config with source .bashrc doesn't fix the issue either.

My questions are:

  1. What is causing the Option+Left/Right shortcuts from working sometimes?
  2. How can I fix this so it doesn't happen again?

This is my .inputrc:

"\e\e[D": backward-word
"\e\e[C": forward-word

Possibly relevant iTerm2 settings: Remap Modifiers Setting Keys in Profile Setting

  • Sounds like this might be specific to iTerm. If so, you might have better chances of getting an answer over at [apple.se]. If you decide to ask there, please remember to delete this one first. – terdon Jul 14 '21 at 10:32
  • Thanks for the Ask Different suggestion. So far I don't know if it's a bash or iTerm problem. – Thomas McGuire Jul 14 '21 at 11:33
  • This will always depend on the terminal you are using, so it is almost certainly an iTerm issue. Different terminals understand different escape sequences in `.inputrc` for some reason I don't know. Does adding (without removing the ones you already have) `"\e[5D": backward-word` and `"\e[5C": forward-word` help? – terdon Jul 14 '21 at 11:47
  • @terdon I've added your suggestions to my `.inputrc`, thanks. I can not tell yet if it worked or not, as my problem only happens sporadically. – Thomas McGuire Jul 14 '21 at 15:42

0 Answers0