less 在 tmux 下将换行视为单行,打破分页

less 在 tmux 下将换行视为单行,打破分页

tmux(v1.8) 中,将less(v458) 与包含比终端宽度长的行的管道或文件一起使用已经开始在 Ubuntu 上给我带来问题。

寻呼机最初滚动到第一行之外,而不是从顶部开始。当我尝试向后滚动时,来自不同行的字符一起跑到一个块中,没有换行符。

有时,像向上翻页(b<C-b>)这样的命令会出现跳转过去的文件末尾,在底部留下一堆行:

some-line
another-line
last-line-in-file
~
~
~
~
~
(END)

从那里开始,寻呼机将永远无法向上滚动。

答案1

在我完成发布之前我就弄清楚了这一点:我已经使用别名lessless -r保留颜色,但显然这样搞砸了更少:

-r or --raw-control-chars
       Causes "raw" control characters to be displayed.  The  default  is  to
       display  control  characters  using the caret notation; for example, a
       control-A (octal 001) is displayed as  "^A".   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

我将删除该别名或尝试使用-R它,它只保留 ANSI 颜色转义序列并且应该在“大多数情况下”工作。

一段时间后,less -R它完全按照我想要的方式工作,并且没有引起任何显示问题。

-R or --RAW-CONTROL-CHARS
       Like -r, but only ANSI "color" escape sequences are  output  in  "raw"
       form.   Unlike  -r,  the  screen appearance is maintained correctly in
       most cases.  ANSI "color" escape sequences are sequences of the form:

            ESC [ ... m

       where the "..." is zero or more color specification characters For the
       purpose  of  keeping  track  of  screen  appearance, ANSI color escape
       sequences are assumed to not move the cursor.  You can make less think
       that  characters other than "m" can end ANSI color escape sequences by
       setting the environment variable LESSANSIENDCHARS to the list of char‐
       acters  which  can end a color escape sequence.  And you can make less
       think that characters other than the standard ones may appear  between
       the ESC and the m by setting the environment variable LESSANSIMIDCHARS
       to the list of characters which can appear.

相关内容