Display Chinese MAN manual in MAC system

Source: Internet
Author: User

Recently, we have translated Chinese MAN manuals and found that MAN commands in MAC systems cannot display Chinese MAN manuals as well as in most Linux distributions.

Based on the searched information, the solution is found:

1. Update the groff package in your system. The groff package in MAC (10.8 and 10.9) is 1.18, which is a few years old. You need to upgrade it, you can download the latest groff 1.22 compilation or install it through port.

2. You need to modify MAN's configuration file:

Sudo vi/private/etc/man. conf

Modify the NROFF configuration:

NROFF preconv-e utf8 |/opt/local/bin/groff-Wall-mtty-char-Tutf8-mandoc-c

In this way, the MAN page encoded by UTF8 can be identified by groff through transcoding.

Modify PAGER configuration:

PAGER/usr/bin/less-isR

In this way, the ANSI Escape Character Sequence on the MAN manual page can be avoided (used to control the formats such as bold)

Save it.

 

By the way, let's talk about how to display MAN in color.

Add the following to the environment variable:

Export GROFF_NO_SGR = 1
Export LESS_TERMCAP_mb = $ '\ E [01; 36m'
Export LESS_TERMCAP_md = $ '\ E [01; 36m'
Export LESS_TERMCAP_me = $ '\ E [0m'
Export LESS_TERMCAP_se = $ '\ E [0m'
Export LESS_TERMCAP_so = $ '\ E [01; 44; 33m'
Export LESS_TERMCAP_ue = $ '\ E [0m'
Export LESS_TERMCAP_us = $ '\ E [01; 33m'

In this way, MAN is the color. If you want to adjust the color, you can modify the above Escape Code accordingly.

However, a side effect of this method is that it will disturb the display of command output such as env.

Therefore, a better solution is to use the env command to redefine the man command environment:

Man (){
Env GROFF_NO_SGR = 1 \
LESS_TERMCAP_mb = $ '\ E [1; 36m '\
LESS_TERMCAP_md = $ '\ E [1; 36m '\
LESS_TERMCAP_me = $ '\ E [0m '\
LESS_TERMCAP_se = $ '\ E [0m '\
LESS_TERMCAP_so = $ '\ E [1; 44; 33m '\
LESS_TERMCAP_ue = $ '\ E [0m '\
LESS_TERMCAP_us = $ '\ E [1; 33m '\
Man "$ @"
}

The above can be put in your/etc/bashrc.

Recommended reading:

IOS 7 Beta 2 released, supporting iPad and iPad Mini

IOS7 Beta 1 Test

IOS 7 beta [Download + tutorial + experience] for iPhone 5, 4S, 4, iPod touch 5

How to activate iOS 7 beta

Apple releases an official version update for iOS 7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.