在Linux和Unix中显示彩色手册页

时间:2020-01-09 10:45:57  来源:igfitidea点击:

如何在Linux/FreeBSD/Apple OS X/Unix等操作系统下的手册页中添加一些颜色?
如何在Linux中查看彩色手册页?
您需要安装一个名为most的寻呼机,才能在Linux和Unix中显示彩色手册页。
它是一个分页程序,一次显示一个窗口,在终端上显示文件的内容。
它在每个窗口填满后暂停,并在窗口状态行上打印,包括文件名,当前行号以及到目前为止显示的文件百分比。
本教程说明如何在Linux,FreeBSD和macOS或者类似Unix的系统中查看彩色手册页。

如何在手册页中查看或者显示颜色

我们将按照以下方式安装最多的软件包,以便可以在终端上看到一个彩色的手册页:

FreeBSD最多安装以在Unix中显示彩色手册页

要安装端口,请执行:

# cd /usr/ports/sysutils/most/
# make install clean

或者,您可以使用以下命令添加名为most的二进制软件包:

# pkg_add -r most

较新版本的FreeBSD用户应使用pkg命令:

# pkg install most

Debian/Ubuntu Linux在Linux中安装了大多数显示丰富多彩的手册页

运行以下apt-get命令或者apt命令:

$ sudo apt-get install most

或者

$ sudo apt install most

输出示例:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  most
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 44.0 kB of archives.
After this operation, 121 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu eoan/universe amd64 most amd64 5.0.0a-4 [44.0 kB]
Fetched 44.0 kB in 1s (48.3 kB/s)
Selecting previously unselected package most.
(Reading database ... 235913 files and directories currently installed.)
Preparing to unpack .../most_5.0.0a-4_amd64.deb ...
Unpacking most (5.0.0a-4) ...
Setting up most (5.0.0a-4) ...
Processing triggers for man-db (2.8.7-3) ...
Processing triggers for mime-support (3.63ubuntu1) ..

在Fedora/RHEL/SL/CentOS Linux下最多安装?

首先,打开并在CentOS和RHEL 7.x上安装EPEL存储库(请参阅此处如何在CentOS 8和RHEL 8上安装EPEL存储库)。
执行以下yum命令以安装最多的软件包:

# yum install most

Fedora Linux用户应执行以下dnf命令:

$ sudo dnf install most

Arch Linux安装最多

尝试使用pacman命令:

sudo pacman -S most

输出示例:

pacman -S most
resolving dependencies...
looking for conflicting packages...
 
Packages (1) most-5.1.0-1
 
Total Installed Size:  0.11 MiB
 
:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring                     [###################] 100%
(1/1) checking package integrity                   [###################] 100%
(1/1) loading package files                        [###################] 100%
(1/1) checking for file conflicts                  [###################] 100%
(1/1) checking available disk space                [###################] 100%
:: Processing package changes...
(1/1) installing most                              [###################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...

macOS安装最多

打开终端应用程序,并运行大多数命令:

brew install most

如何在Linux或者Unix中查看彩色手册页

输入以下命令来设置PAGER bash shell变量,执行:

export PAGER="most"
### 或者#
export PAGER="/usr/bin/most -s"

我建议您在~/.bashrc文件中修改和设置称为PAGER的环境变量,如下所示:

echo 'export PAGER="most"' >> ~/.bashrc

有关CSH/TCSH Shell用户的说明

在CSH/tcsh shell用户中,执行以下命令:

## csh / tcsh syntax ##
setenv PAGER /usr/local/bin/most

如何查看彩色手册页

尝试查看手册页以获取任何命令。
例如,要查看Linux date命令的手册页,请执行:

$ man date

要退出,请按q。

大多数命令摘要

像许多Unix命令一样,大多数命令都有大量的选项和键盘快捷键。
因此,我将总结常用的选项:

Quitting:

  Q                      Quit MOST.
  :N,:n                  Quit this file and view next.
                            (Use UP/DOWN arrow keys to select next file.)

Movement:

  SPACE, D              *Scroll down one Screen.
  U, DELETE             *Scroll Up one screen.
  RETURN, DOWN          *Move Down one line.
  UP                    *Move Up one line.
  T                      Goto Top of File.
  B                      Goto Bottom of file.
  > , TAB                Scroll Window right
  <                      Scroll Window left
  RIGHT                  Scroll Window left by 1 column
  LEFT                   Scroll Window right by 1 column
  J, G                   Goto line.
  %                      Goto percent.

Window Commands:

  Ctrl-X 2, Ctrl-W 2     Split window.
  Ctrl-X 1, Ctrl-W 1     Make only one window.
  O, Ctrl-X O            Move to other window.
  Ctrl-X 0               Delete Window.

Searching:

  S, f, /               *Search forward
  ?                     *Search Backward
  N                     *Find next in current search direction.

Miscellaneous:

  W                      Toggle width between 80 and 132 char mode.
  Ctrl-X Ctrl-F          Read a file from disk
  R, Ctrl-R              Redraw Screen.
  F                      Simulate tail -f mode
  :o                     Toggle options:  b-binary, w-wrap, t-tab
  E                      Edit file.  Uses MOST_EDITOR and EDITOR
                           environment variables.

*Note:  This command Jan be repeated `n' times By entering a number then
        the command key, e.g.,  '5 SPACE' moves 5 screens forward.