[英]Change width of man command ouput
我經常使用 Guake 終端模擬器。 這是自從切片培育 IMO 以來最好的東西。
但是有一件事一直困擾着我,當我想閱讀手冊頁時,輸出的默認寬度是終端窗口的寬度,在我的情況下,它始終是全屏的,因此閱讀起來有點困難。
有沒有辦法可以使 man 命令 a 的輸出默認寬度為 80 個字符,易於閱讀?
man 的手冊頁有這部分:
MANWIDTH If $MANWIDTH is set, its value is used as the line length for which manual pages should be formatted. If it is not set, manual pages will be formatted with a line length appropriate to the current terminal (using an ioctl(2) if available, the value of $COLUMNS, or falling back to 80 characters if neither is available). Cat pages will only be saved when the default formatting can be used, that is when the terminal line length is between 66 and 80 characters.
但我不知道在哪里改變它。
我嘗試添加以下行:
曼威 80
到 /etc/manpath.config 和 ~/.bashrc,但沒有結果。
那是環境變量。
嘗試:
MANWIDTH=80
export MANWIDTH
man bash
如果您想要永久設置,那么您可以將前兩行添加到您的 shell 會話啟動腳本或類似腳本中。
正如其他答案中指出的那樣,正確設置和導出MANWIDTH
是要走的路。
我會避免對其進行硬編碼,否則當您的終端模擬器窗口比該值更窄時,它會溢出/有丑陋的換行符:
NAME
grep, egrep, fgrep - print lines that match
patterns
SYNOPSIS
grep [OPTION...] PATTERNS [FILE...]
grep [OPTION...] -e PATTERNS ... [FILE...]
grep [OPTION...] -f PATTERN_FILE ... [FILE.
..]
DESCRIPTION
grep searches for PATTERNS in each FI
LE. PATTERNS is one or more
patterns separated by newline characters, a
nd grep prints each line
that matches a pattern. Typically PATTERN
S should be quoted when grep
is used in a shell command.
這是我使用的一個方便的別名:
alias man='MANWIDTH=$((COLUMNS > 80 ? 80 : COLUMNS)) man'
如果終端窗口比它寬,這將MANWIDTH
設置為 80,如果它更窄,則設置為COLUMNS
(終端窗口的當前寬度)。
結果在一個寬窗口中:
NAME
grep, egrep, fgrep - print lines that match patterns
SYNOPSIS
grep [OPTION...] PATTERNS [FILE...]
grep [OPTION...] -e PATTERNS ... [FILE...]
grep [OPTION...] -f PATTERN_FILE ... [FILE...]
DESCRIPTION
grep searches for PATTERNS in each FILE. PATTERNS is one or more
patterns separated by newline characters, and grep prints each line
that matches a pattern. Typically PATTERNS should be quoted when grep
is used in a shell command.
結果在一個狹窄的窗口中:
NAME
grep, egrep, fgrep - print lines that
match patterns
SYNOPSIS
grep [OPTION...] PATTERNS [FILE...]
grep [OPTION...] -e PATTERNS ...
[FILE...]
grep [OPTION...] -f PATTERN_FILE ...
[FILE...]
DESCRIPTION
grep searches for PATTERNS in each
FILE. PATTERNS is one or more
patterns separated by newline
characters, and grep prints each line
that matches a pattern. Typically
PATTERNS should be quoted when grep is
used in a shell command.
您需要將其設置為環境變量。
MANWIDTH=80 man man
在這里工作,並提供了聯機幫助man
在80列的榮耀。
如果你想在.bashrc
,正確的行條目是
export MANWIDTH=80
注意=
符號周圍缺少空格。 您可能需要也可能不需要export
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.