If you just want the section headings, grep
for them. They are in ALLCAPS and are the only lines that have no leading spaces:
$ man bash | grep '^[A-Z]'
BASH(1) General Commands Manual BASH(1)
NAME
SYNOPSIS
COPYRIGHT
DESCRIPTION
OPTIONS
ARGUMENTS
INVOCATION
DEFINITIONS
RESERVED WORDS
SHELL GRAMMAR
COMMENTS
QUOTING
PARAMETERS
EXPANSION
REDIRECTION
ALIASES
FUNCTIONS
ARITHMETIC EVALUATION
CONDITIONAL EXPRESSIONS
SIMPLE COMMAND EXPANSION
COMMAND EXECUTION
COMMAND EXECUTION ENVIRONMENT
ENVIRONMENT
EXIT STATUS
SIGNALS
JOB CONTROL
PROMPTING
READLINE
HISTORY
HISTORY EXPANSION
SHELL BUILTIN COMMANDS
RESTRICTED SHELL
SEE ALSO
FILES
AUTHORS
BUG REPORTS
BUGS
GNU Bash 4.3 2014 February 2 BASH(1)
This is controlled via MANPAGER
.
Manual pages
defaults to the pager
of less -is
.
You can just highlight the current selection:
man -P "less -isg" <command>
Or set the MANPAGER
variable:
export MANPAGER="less -isg"
You could also use vim
where the cursor is highlighted so the current selection will appear differently.:
man -P "sh -c \"col -b | vim -c 'set ft=man ts=8 nomod nolist nonu' \
-c 'nnoremap i <nop>' \
-c 'nnoremap <Space> <C-f>' \
-c 'noremap q :quit<CR>' -\"" <command>
Taken from Zameer Manji:
- ft=man enables the coloring of the man page.
- ts=8 ensures the width of tab characters matches less.
- nomod removes the modification warning when trying to quit.
- nonu removes line numbers.
- nolist disables listchars so trailing whitespace and extra tabs are not highlighted.
- nnoremap i ensures that we do not accidentally enter insert mode when viewing the man page.
Plus my own option to use space to paginate and quit
with q
:
-c 'nnoremap <Space> <C-f>'
-c 'noremap q :quit<CR>'
Set it as your default pager by adding it to your default profile:
export MANPAGER="sh -c \"col -b | vim -c 'set ft=man ts=8 nomod nolist nonu' \
-c 'nnoremap i <nop>' \
-c 'nnoremap <Space> <C-f>' \
-c 'noremap q :quit<CR>' -\""
Best Answer
Try this trick:
or
With a backslash before the
+
sign because what comes after/
is an extended regular expression.