如何编辑联机帮助页?

bha*_*159 5 command-line manpage

我想知道是否可以编辑联机帮助页。如果是如何?(如果可能,通过在 gedit 中更改)。

PS-我想知道是否可以编辑已经编写的联机帮助页(只是为了好玩)。

ter*_*don 8

是的,可以,但不建议这样做。最好的方法可能类似于 Rinzwind 建议的工具,但是,您也可以手动执行此操作。我将使用该man页面grep作为示例。

  1. 手册页是压缩文件,因此您要么需要使用真正的编辑器,例如emacs可以读取/写入压缩文件的编辑器,要么必须首先将其解压缩:

    sudo gunzip /usr/share/man/man1/grep.1.gz
    
    Run Code Online (Sandbox Code Playgroud)
  2. 编辑它:

    sudo gedit /usr/share/man/man1/grep.1
    
    Run Code Online (Sandbox Code Playgroud)

    现在,格式有点奇怪。但是,如果您只想更改简单的内容,则可以忽略格式并仅更改纯文本。例如,我可以很容易地更改 的描述grepgedit当您在(或任何其他编辑器)中打开文件时,前几行如下所示:

    .\" GNU grep man page
    .if !\n(.g \{\
    .   if !\w|\*(lq| \{\
    .       ds lq ``
    .       if \w'\(lq' .ds lq "\(lq
    .   \}
    .   if !\w|\*(rq| \{\
    .       ds rq ''
    .       if \w'\(rq' .ds rq "\(rq
    .   \}
    .\}
    .
    .ie \n[.g] .mso www.tmac
    .el \{\
    . de MTO
    \\$2 \(laemail: \\$1 \(ra\\$3
    ..
    . de URL
    \\$2 \(laURL: \\$1 \(ra\\$3
    ..
    .\}
    .
    .TH GREP 1 \*(Dt "GNU grep 2.25" "User Commands"
    .hy 0
    .
    .SH NAME
    grep, egrep, fgrep \- print lines matching a pattern
    .
    .SH SYNOPSIS
    .B grep
    .RI [ OPTIONS ]
    .I PATTERN
    .RI [ FILE .\|.\|.]
    .br
    .B grep
    .RI [ OPTIONS ]
    .RB [ \-e
    .I PATTERN
    |
    .B \-f
    .IR FILE ]
    .RI [ FILE .\|.\|.]
    .
    .SH DESCRIPTION
    .B grep
    searches the named input
    .IR FILE s
    for lines containing a match to the given
    .IR PATTERN .
    If no files are specified, or if the file
    .RB "\*(lq" \- "\*(rq"
    is given,
    .B grep
    searches standard input.
    By default,
    .B grep
    prints the matching lines.
    .PP
    In addition, the variant programs
    
    Run Code Online (Sandbox Code Playgroud)

    因此,要更改描述,我可能会将其更改为(向下滚动到“描述”部分):

    .\" GNU grep man page
    .if !\n(.g \{\
    .   if !\w|\*(lq| \{\
    .       ds lq ``
    .       if \w'\(lq' .ds lq "\(lq
    .   \}
    .   if !\w|\*(rq| \{\
    .       ds rq ''
    .       if \w'\(rq' .ds rq "\(rq
    .   \}
    .\}
    .
    .ie \n[.g] .mso www.tmac
    .el \{\
    . de MTO
    \\$2 \(laemail: \\$1 \(ra\\$3
    ..
    . de URL
    \\$2 \(laURL: \\$1 \(ra\\$3
    ..
    .\}
    .
    .TH GREP 1 \*(Dt "GNU grep 2.25" "User Commands"
    .hy 0
    .
    .SH NAME
    grep, egrep, fgrep \- print lines matching a pattern
    .
    .SH SYNOPSIS
    .B grep
    .RI [ OPTIONS ]
    .I PATTERN
    .RI [ FILE .\|.\|.]
    .br
    .B grep
    .RI [ OPTIONS ]
    .RB [ \-e
    .I PATTERN
    |
    .B \-f
    .IR FILE ]
    .RI [ FILE .\|.\|.]
    .
    .SH DESCRIPTION
    .B grep
    searches for and destroys all the unicorns on your system.
    .PP
    In addition, the variant programs
    
    Run Code Online (Sandbox Code Playgroud)
  3. 保存文件,退出gedit,然后重新压缩它(这实际上不需要,man grep已经可以工作,但最好保持整洁):

    sudo gzip /usr/share/man/man1/grep.1
    
    Run Code Online (Sandbox Code Playgroud)

现在,只要运行man grep你就会看到:

GREP(1)

NAME
       grep, egrep, fgrep - print lines matching a pattern

SYNOPSIS
       grep [OPTIONS] PATTERN [FILE...]
       grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]

DESCRIPTION
       grep searches for and destroys all the unicorns on your system.

       In addition, the variant programs egrep and fgrep are the same as grep -E and grep -F, respectively.  These variants are deprecated, but are provided
       for backward compatibility.
Run Code Online (Sandbox Code Playgroud)


Rin*_*ind 5

安装gmanedit

Gtk+ Manpages Editor 是一个使用 GTK+ 在 X 上运行的手册页编辑器。

Gmanedit是一个应用程序,它允许您在 Linux/Unix 系统上编辑手册页 (man)。

它就像最常见的 HTML 编辑器,但更简单。您需要了解联机帮助页格式。

更新:既然 gmanedit 已经死了,试试它的 fork gmanedit2