Less
tmux 下的 less 將換行視為單行,打破分頁
在
tmux
(v1.8) 中,將less
(v458) 與包含比終端寬度更長的行的管道或文件一起使用已經開始在 Ubuntu 上給我帶來問題。尋呼機最初滾動超出第一行而不是從頂部開始。當我嘗試向後滾動時,來自不同行的字元會一起執行到一個沒有換行符的塊中。
有時,像 page up (
b
或<C-b>
) 這樣的命令似乎跳過了文件的末尾,在底部留下了一堆行:some-line another-line last-line-in-file ~ ~ ~ ~ ~ (END)
從那裡,尋呼機永遠無法向上滾動。
我在發完文章之前就想到了這一點:我為了保留顏色而使用了別名
less
,less -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.