正如其他答案中指出的那样,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.