Tmux 换行指示器

Tmux 换行指示器

我想一目了然地看到我的 tmux 终端动态包装输出行的位置:包装行当前如下所示:

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

相反,我希望它看起来像这样:

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

下面vim我就用它set breakindentopt sbr=>>>来达到这个效果。 tmux 有类似的选项吗?

答案1

我不知道这是否可行,但也对解决方案感兴趣。您可以使用以下bash脚本来模拟类似的行为,但它根本没有经过测试,它可能已经在简单的用例中中断。

#!/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

该脚本的作用是循环遍历其参数 ( $@),然后打印一行输出,并将$wrap变量添加到以下输出行。它独立于它tmux,并且可以在其内部或外部使用。将脚本存储在名为eg的文件中wrapper,然后像这样调用它:

$ 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.

echo "$x"请注意和之间的输出差异wrapper echo "$x"

相关内容