4

I would like to see at a glance where my tmux terminal dynamically wraps output lines: A wrapped line currently looks like this:

This is a very long sentence that did not
fit on one screen line.

Instead, I would like it to look, for example, like this:

This is a very long sentence that did not
>>> fit on one screen line.

Under vim I'd use set breakindentopt sbr=>>> to achieve this effect. Is there a similar option for tmux?

1

I don't know if this is possible, but would be interested in a solution as well. You can use the following bash script to simulate a similar behavior, but it's not tested at all, it might break already on simple use cases.

#!/usr/bin/env bash

cols=$(tput cols)
colsi=$((${cols} + 1))
wrap='>>> '

$@ | while IFS='' read -r line; do
    while [ ${#line} -gt ${#wrap} ]; do
        echo "${line}" | cut -c-"${cols}"
        line="${wrap}"$(echo "${line}" | cut -c"${colsi}"-)
    done
done

What this script does, is looping over its arguments ($@) and then print one line of output, and prepending the $wrap variable to the following output lines. It is independent of tmux and can be used in- or outside of it. Store the script with a file called e.g. wrapper and then call it like this:

$ x='This is just a very long silly line, it should show the use case of the wrapper script, that means the only thing this silly text is supposed to do, is to be long enough to be wrapped. Since I dont know what resolution you have on your screen, you might want to extend this line yourself to make sure it is wrapped.'

$ echo "$x"
> This is just a very long silly line, it should show the use case of the wrapper script, that means the only thing this silly text is supposed to do, is to be long enough to be wrapped. Since
> I dont know what resolution you have on your screen, you might want to extend this line yourself to make sure it is wrapped.

$ wrapper echo "$x"
> This is just a very long silly line, it should show the use case of the wrapper script, that means the only thing this silly text is supposed to do, is to be long enough to be wrapped. Since
> >>> I dont know what resolution you have on your screen, you might want to extend this line yourself to make sure it is wrapped.

Note the difference of the output between echo "$x" and wrapper echo "$x".

| improve this answer | |
  • Thanks. It loses the nice dynamic resizing behavior of tmux, but at least it is a decent work around. It's a real pity that there seems to be nothing within tmux. – klimpergeist Feb 8 '16 at 20:10

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.