1

TL;RD less -S -R gives colored output but lines still wrapped to next line.

I'm requesting a http service (instagram api) which gives me json encoded data. I use prettyjson from npm to see colored output. But some lines are too long, so they are wrapped by terminal. I want to enable horizontal scroll by using less. Horizontal scroll works by arrow keys, but lines still wrapped to next line

Look at last lines with thumbnail_src and display_src screenshot of termnal app in OSX screenshot of terminal app in OSX

  • 1
    The title of that window shows you're using less -R, not less -RS. If you type -S from within less, does that remove the wrapping? – Stéphane Chazelas Nov 21 '16 at 7:47
1

By reading unix stackexchange I found the answer:

Warning: when the -r option is used, less cannot keep track of the actual appearance of the screen (since this depends on how the screen responds to each type of control character). Thus, various display problems may result, such as long lines being split in the wrong place.

link to comment

  • less -R is supposed to be the fix to that. Unlike -r, the screen appearance is maintained correctly in most cases. (repeat 10 seq 100 | paste -sd - -) | grep --color=always '[0-9]' | less -RS (zsh syntax) works OK for me. Possibly less cannot determine the width of your terminal. – Stéphane Chazelas Nov 21 '16 at 7:43

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.