How to turn off word wrap in iTerm2?

UnixTerminalItermIterm2

Unix Problem Overview


How to turn off word wrap in iTerm2? Is there a specific command to do so or in the preferences? I am trying to avoid having the text run down to the next line. I would rather scroll side to side.

Unix Solutions


Solution 1 - Unix

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 - Unix

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 - Unix

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBeast_CodeView Question on Stackoverflow
Solution 1 - UnixMike DView Answer on Stackoverflow
Solution 2 - UnixGreg HView Answer on Stackoverflow
Solution 3 - UnixZilbert97View Answer on Stackoverflow