Change width of man command ouput Change width of man command ouput linux linux

Change width of man command ouput


That's an environment variable.

Try:

MANWIDTH=80export MANWIDTHman bash

If you want that set permanently then you can add those first two lines to your shell session startup scripts or similar.


As pointed out in other answers, setting and exporting MANWIDTH properly is the way to go.

I would avoid hardcoding it, or else it will overflow / have ugly linebreaks when your terminal emulator window is more narrow than that value:

NAME       grep, egrep, fgrep - print lines that match patternsSYNOPSIS       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.

Here's what I use, in a handy alias:

alias man='MANWIDTH=$((COLUMNS > 80 ? 80 : COLUMNS)) man'

This sets MANWIDTH to 80 if the terminal window is wider than that, and to COLUMNS (the current width of the terminal window) if it is more narrow.

Result in a wide window:

NAME       grep, egrep, fgrep - print lines that match patternsSYNOPSIS       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.

Result in a narrow window:

NAME       grep,  egrep, fgrep - print lines that       match patternsSYNOPSIS       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.


You need to set this as an environment variable.

MANWIDTH=80 man man

works here, and provides the manpage for man in 80 column glory.

If you want this in .bashrc the correct line entry is

export MANWIDTH=80

Note lack of spaces around = sign. You may or may not need export.