How to turn off word wrap in iTerm2?

Solution 1:

lifted directly from https://apple.stackexchange.com/a/210666/115119

Props to @michid

Disable line wrapping:

tput rmam

Enable line wrapping:

tput smam

Solution 2:

It appears that iTerm2 does not have the ability to turn off word wrap. There is an open issue (iTerm2 issue #1790) reported to "Provide toggle to turn on/off line wrapping".

The description of that issue reads:

Looks like a conversation was had in the Google Groups about this but no one ever actually filed a feature request.

http://groups.google.com/group/iterm2-discuss/browse_thread/thread/e0f4e9b552d8acd4

In general I don't like having horizontal scrollbars and prefer to have the lines wrap, but there are occasions...such as looking at long stack traces, that I'd rather just have sequentially indented lines line up and just be forced to scroll to the right to expose all the details. To accomplish this task now, I end up making the text incredibly small so I can read stack traces lined up, but even that doesn't always work.

In October, 2014, the creator of iTerm2 commented regarding the feature request to toggle word wrap, "I'd like to do this but it's a lot of work, so feel free to send a pull request, but don't be [a jerk]."

In April, 2015, the milestone for the feature request was changed to "Future Release".

Solution 3:

For me, my issue was purely down to the configuration of my PS1 - not what I had originally expected!

The key for me was surrounding the following with any characters that wouldn't be printed as in your prompt - such as encoding colours. Sourced from https://linoxide.com/how-tos/change-bash-prompt-variable-ps1/

\[ This sequence should appear before a sequence of characters that don’t move the cursor (like color escape sequences). This allows bash to calculate word wrapping correctly. \] This sequence should appear after a sequence of non-printing characters.