[英]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.