Enter key prints ^M in certain situations in iTerm

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


I restarted iterm tab and it got fixed.