blog:writing_custom_man_pages
Differences
This shows you the differences between two versions of the page.
blog:writing_custom_man_pages [2010-09-19 06:53] – created brb | blog:writing_custom_man_pages [2010-09-19 06:54] (current) – brb | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Writing custom man pages ====== | ====== Writing custom man pages ====== | ||
- | Creating Custom Man Pages | + | ===== Manuals |
- | Sep 09, 2010 By Pete Vargas Mas | + | |
- | in | + | |
- | + | ||
- | * HOW-TOs | + | |
- | * manual | + | |
- | * SysAdmin | + | |
- | + | ||
- | Manuals | + | |
- | + | ||
- | Man pages have been the primary source for UN*x documentation for a long time. Whenever I create a script that's going to be around for a while, I create documentation in the form of a section 1 man page. This stops my cell phone from ringing on the weekends when the junior sysadmins are looking for my notes. | + | |
- | + | ||
- | Some people I know tend to shy away from writing man pages because they believe it's too difficult to learn how to correctly format man pages using troff or groff. Lucky for me, there' | + | |
Marc Vertes (mvertes@free.fr) has written an excellent GNU AWK script called txt2man, which can run on almost any UN*X-like system, and can convert a flat ASCII text file to the correct man page format. txt2man (currently version 1.5.5-1) is distributed by the Fedora Project and is available from the EPEL Repository. The authors home page is http:// | Marc Vertes (mvertes@free.fr) has written an excellent GNU AWK script called txt2man, which can run on almost any UN*X-like system, and can convert a flat ASCII text file to the correct man page format. txt2man (currently version 1.5.5-1) is distributed by the Fedora Project and is available from the EPEL Repository. The authors home page is http:// | ||
Line 22: | Line 10: | ||
Using the command: | Using the command: | ||
- | + | | |
- | $ txt2man -h 2>&1 | txt2man -T | + | |
will display the built-in help and pipe it through txt2man to produce a formatted man page and preview it with the default pager. The same command, without the " | will display the built-in help and pipe it through txt2man to produce a formatted man page and preview it with the default pager. The same command, without the " | ||
- | + | | |
- | $ txt2man -h 2>&1 | txt2man > txt2man.1 | + | |
and use gzip to compress the resulting file: | and use gzip to compress the resulting file: | ||
- | + | | |
- | $ gzip txt2man.1 | + | |
we can view the file as a regular man page: | we can view the file as a regular man page: | ||
- | + | | |
- | $ man ./ | + | |
Notice I specified section 1 for my man page. By default, man will look for System Administration commands in section 8 and General Commands in section 1. | Notice I specified section 1 for my man page. By default, man will look for System Administration commands in section 8 and General Commands in section 1. | ||
Line 41: | Line 25: | ||
Now, all we need to do is copy our new man page to the appropriate directory for our system, as specified in the $MANPATH environment variable, or maybe in / | Now, all we need to do is copy our new man page to the appropriate directory for our system, as specified in the $MANPATH environment variable, or maybe in / | ||
- | $ cp ./ | + | |
Finally, I update the whatis database with: | Finally, I update the whatis database with: | ||
+ | # / | ||
- | # / | + | and now my man page is available to all users. |
- | and now my man page is available to all users. | + | |
+ | Sep 09, 2010 By Pete Vargas Mas | ||
Ref: | Ref: |
blog/writing_custom_man_pages.1284871984.txt.gz · Last modified: 2010-09-19 06:53 by brb