2

I am using iTerm2 on a Macbook Pro running MacOS Mojave.

In certain situations, such as when doing a git add -p, pressing return ends up printing ^M instead of performing the action.

Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? ^M

Actual demo output

That means I am unable to take any action on a hunk as I cannot submit any of the given choices.


I though this could be because of how git handles returns, so I modified the core.autocrlf config but none of its valid values cause any change in this behaviour.

Then when trying other methods I relaized that this problem is visible only when using iTerm and NOT the Terminal app despite using zsh in both.


What configuration should I modify to allow for the return key to behave normally in this case?

  • By any chance... do you press accidentally CTRL+V before hitting the ENTER key? In the standard zsh keybindings CTRL+V (^V) this is bound to quoted-insert, i.e. the next pressed key is inserted literally. ^M for ENTER, ^[ for ESC and so on. – mpy Feb 7 '19 at 17:37
  • @mpy Did not know about that. Tried carefully again, same behaviour observed – Sinstein Feb 8 '19 at 10:33
1

This problem occurs because of odd terminal line settings. The stty tool on Unix can help you get this fixed. I have had the same issue on Iterm2 on Mac and got it fixed using.

stty sane

This command fixes terminal oddities and make it usable. Here's a good read for more info. http://www.peachpit.com/articles/article.aspx?p=659655&seqNum=13

| improve this answer | |
0

I restarted iterm tab and it got fixed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.