前置条件:需要brew
网上很多使用 https://github.com/man-pages-zh/manpages-zh来配置mac里中文man手册的,但是这种方法配置出来的man的用法与实际用法可能并不一致,且该过程复杂,需要本地clone再cmake,极其麻烦
本文给出一种使用第三方库man-db来替换原本man来配置man中文手册的方法
Step1:按照man-db
brew install man-db
安装log
brew install man-db
==> Downloading https://formulae.brew.sh/api/cask.jws.json
################################################## 81.9%curl: (28) Operation too slow. Less than 100 bytes/sec transferred the last 5 seconds
Warning: cask.jws.json: update failed, falling back to cached version.
==> Downloading https://formulae.brew.sh/api/cask.jws.json
############ 20.0%curl: (28) Operation too slow. Less than 100 bytes/sec transferred the last 5 seconds
Warning: cask.jws.json: update failed, falling back to cached version.
==> Downloading https://formulae.brew.sh/api/cask.jws.json
############################################################## 100.0%
==> Fetching dependencies for man-db: jbig2dec, libidn, ghostscript, jasper, netpbm, libpaper, psutils, uchardet, groff and libpipeline
==> Fetching jbig2dec
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/jbig2dec
############################################################## 100.0%
==> Fetching libidn
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/libidn-1
############################################################## 100.0%
==> Fetching ghostscript
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/ghostscr
############################################################## 100.0%
==> Fetching jasper
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/jasper-4
############################################################## 100.0%
==> Fetching netpbm
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/netpbm-1
############################################################## 100.0%
==> Fetching libpaper
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/libpaper
############################################################## 100.0%
==> Fetching psutils
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/psutils-
############################################################## 100.0%
==> Fetching uchardet
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/uchardet
############################################################## 100.0%
==> Fetching groff
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/groff-1.
############################################################## 100.0%
==> Fetching libpipeline
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/libpipel
############################################################## 100.0%
==> Fetching man-db
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/man-db-2
############################################################## 100.0%
==> Installing dependencies for man-db: jbig2dec, libidn, ghostscript, jasper, netpbm, libpaper, psutils, uchardet, groff and libpipeline
==> Installing man-db dependency: jbig2dec
==> Pouring jbig2dec-0.19.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/jbig2dec/0.19: 13 files, 420.3KB
==> Installing man-db dependency: libidn
==> Pouring libidn-1.41.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/libidn/1.41: 73 files, 1MB
==> Installing man-db dependency: ghostscript
==> Pouring ghostscript-10.01.1_1.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/ghostscript/10.01.1_1: 645 files, 151.3MB
==> Installing man-db dependency: jasper
==> Pouring jasper-4.0.0.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/jasper/4.0.0: 44 files, 1.6MB
==> Installing man-db dependency: netpbm
==> Pouring netpbm-10.86.38_1.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/netpbm/10.86.38_1: 408 files, 18.5MB
==> Installing man-db dependency: libpaper
==> Pouring libpaper-2.1.0.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/libpaper/2.1.0: 17 files, 266.4KB
==> Installing man-db dependency: psutils
==> Pouring psutils-2.10.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/psutils/2.10: 26 files, 140.6KB
==> Installing man-db dependency: uchardet
==> Pouring uchardet-0.0.8.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/uchardet/0.0.8: 17 files, 652.1KB
==> Installing man-db dependency: groff
==> Pouring groff-1.22.4_1.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/groff/1.22.4_1: 777 files, 24.2MB
==> Installing man-db dependency: libpipeline
==> Pouring libpipeline-1.5.7.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/libpipeline/1.5.7: 79 files, 236KB
==> Installing man-db
==> Pouring man-db-2.11.2.arm64_ventura.bottle.tar.gz
==> Caveats
Commands also provided by macOS have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "bin" directory to your PATH from your bashrc like:
PATH="/opt/homebrew/opt/man-db/libexec/bin:$PATH"
==> Summary
🍺 /opt/homebrew/Cellar/man-db/2.11.2: 67 files, 2.1MB
==> Running `brew cleanup man-db`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> man-db
Commands also provided by macOS have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "bin" directory to your PATH from your bashrc like:
PATH="/opt/homebrew/opt/man-db/libexec/bin:$PATH"
Step2:设置系统变量Lang
PATH="/opt/homebrew/opt/man-db/libexec/bin:$PATH"
export LANG=zh_CN.UTF-8
配置该系统变量即可,这里笔者用的是zsh
open ~/.zshrc
新增并保存即可
最后重载终端
可以看到已经生效