The native environment | version |
---|---|
macOS | Big Sur 11.3.1 |
What is man?
Man, the most important manual tool for Unix-like systems, is pre-installed on the MAC, so we can use man to query the use of various commands. However, the manual inside is all in English, which is not convenient for those who are not good at English to read, so we need to install a Chinese document to facilitate reading and improve work efficiency.
Download Chinese documents using WGET
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/manpages-zh/manpages-zh-1.5.1.tar.gz --no-check-certificate
Copy the code
If wget is not installed, you can install wget directly from the brew command:
brew install wget
Copy the code
Possible errors: The solution
[Homebrew Bottles source using help] introduced Homebrew address is: mirrors.ustc.edu.cn/homebrew-bo… Run the brew config can see HOMEBREW_BOTTLE_DOMAIN: mirrors.ustc.edu.cn/homebrew-bo…
The solution is to change the environment variable to the correct HOMEBREW_BOTTLE_DOMAIN
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zshrc
source ~/.zshrc
Copy the code
Unzip man Pages
The tar ZXVF manpages - useful - 1.5.1. Tar. GzCopy the code
If there are no permissions issues, you can prefix the command with sudo
The installation
First go to the decompressed folder manpages-zh-1.5.1
CD manpages - useful - 1.5.1Copy the code
Then perform
./configure --disable-zhtw
Copy the code
Where –disable-zhtw means that traditional Chinese is not installed. To install traditional Chinese, you need to configure something else. I’m gonna go ahead and install it
$ make && make install
Copy the code
Configure an alias
/usr/local/share/man/zh_CN /usr/local/share/man/zh_CN /usr/local/share/man/zh_CN When the man command is favorable, Chinese will be displayed. Press q to exit. However, this approach is somewhat problematic, using the alias method can better handle the problem. Edit the. Bashrc file using the vim command
vim ~/.bashrc
Copy the code
Add the following statement at the end of the file, then save and exit
alias wman='man -M /usr/local/share/man/zh_CN'
Copy the code
Make the configuration work
source .bashrc
Copy the code
Now that the alias configuration is in effect, you can view all the alias configurations using the following command
alias
Copy the code
It is now possible to call the wman + command name query command, but Chinese garbled characters are now possible
Solve Chinese garbled characters
The main reason for garbled characters is that the groff version of the MAC is older. You can use the following command to check the version
groff -v
Copy the code
Generally, version 1.22 is acceptable. If the version is earlier than 1.22, you can directly upgrade the brew command
brew upgrade groff
Copy the code
After the upgrade is successful, change the /etc/man.conf configuration
sudo vim /etc/man.conf
Copy the code
Add the following statement at the end of the file, then save and exit
// Transcode UTF8 encoded MAN pages to be recognized by Groff. NROFF preconv - e UTF8 | / usr/local/bin/it - Tutf8 - mandoc - c / / avoid MAN MAN page the ANSI Escape character sequence interference (used to control the display bold format) PAGER /usr/bin/less -isRCopy the code
Restart the terminal and try the wman command defined earlier, and it will display normally. There are still some minor display issues, but they are all acceptable. The following statement is used to query the usage of the ls command
man ls
Copy the code
The restart terminal command is invalid
The bashrc file is not automatically loaded after the restart, which will cause the customized alias command to be invalid. Go to the user folder and find the.bash_profile file
cd ~ && ls -a
Copy the code
If you don’t have a.bash_profile file, you need to manually create one,
touch .bash_profile
Copy the code
If so, add the following command at the end of the file to load. Bashrc
source ~/.bashrc
Copy the code
You should be able to restart the terminal now. ZSH overwrites some system shell variables, so the.bash_profile file is not automatically called when the terminal is opened, so we can call.bash_profile in ZSHRC.
vim ~/.zshrc
source ~/.bash_profile
Copy the code
The results are as follows:
Some commands do not have Chinese documents, or can only read English documents. ð
References:
Install the man command on Mac
MAC, Linux man Chinese technology | show Chinese man manual MAC system
Brew Install 404: Bottle missing, falling back to the default domain…