更改 man 命令输出的宽度
Change width of man command ouput
我经常使用瓜客终端模拟器。这是 IMO 切片以来最好的东西。
但有一件事一直困扰着我,当我想阅读手册页时,输出的默认宽度是终端的宽度 windows,在我的情况下,它总是全屏,所以有点难以阅读。
有没有办法让 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.
但我不知道在哪里更改它。
我尝试添加以下行:
MANWIDTH 80
到 /etc/manpath.config 和 ~/.bashrc,但没有结果。
您需要将其设置为环境变量。
MANWIDTH=80 man man
在这里工作,并在 80 专栏 glory 中为 man
提供联机帮助页。
如果你想在 .bashrc
中使用这个,正确的行条目是
export MANWIDTH=80
请注意 =
符号周围缺少空格。您可能需要也可能不需要 export
.
这是一个环境变量。
尝试:
MANWIDTH=80
export MANWIDTH
man bash
如果您希望永久设置该设置,则可以将前两行添加到您的 shell 会话启动脚本或类似脚本中。
正如其他答案中指出的那样,正确设置和导出 MANWIDTH
是正确的方法。
我会避免对其进行硬编码,否则当您的终端仿真器 window 比该值更窄时,它会溢出/出现丑陋的换行符:
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'
如果终端 window 比它宽,则将 MANWIDTH
设置为 80,如果是 COLUMNS
(终端 window 的当前宽度)更窄。
结果很宽 window:
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.
结果缩小 window:
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.
我经常使用瓜客终端模拟器。这是 IMO 切片以来最好的东西。
但有一件事一直困扰着我,当我想阅读手册页时,输出的默认宽度是终端的宽度 windows,在我的情况下,它总是全屏,所以有点难以阅读。
有没有办法让 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.
但我不知道在哪里更改它。
我尝试添加以下行:
MANWIDTH 80
到 /etc/manpath.config 和 ~/.bashrc,但没有结果。
您需要将其设置为环境变量。
MANWIDTH=80 man man
在这里工作,并在 80 专栏 glory 中为 man
提供联机帮助页。
如果你想在 .bashrc
中使用这个,正确的行条目是
export MANWIDTH=80
请注意 =
符号周围缺少空格。您可能需要也可能不需要 export
.
这是一个环境变量。
尝试:
MANWIDTH=80
export MANWIDTH
man bash
如果您希望永久设置该设置,则可以将前两行添加到您的 shell 会话启动脚本或类似脚本中。
正如其他答案中指出的那样,正确设置和导出 MANWIDTH
是正确的方法。
我会避免对其进行硬编码,否则当您的终端仿真器 window 比该值更窄时,它会溢出/出现丑陋的换行符:
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'
如果终端 window 比它宽,则将 MANWIDTH
设置为 80,如果是 COLUMNS
(终端 window 的当前宽度)更窄。
结果很宽 window:
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.
结果缩小 window:
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.