Mac里使用man-db实现中文man

文章介绍了如何通过brew安装man-db来替代man-pages-zh,以简化在macOS上配置中文man手册的过程。方法包括使用brew安装man-db及其依赖,并设置系统变量LANG为zh_CN.UTF-8,以实现中文支持。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前置条件:需要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

新增并保存即可

image-20230429154742573

最后重载终端

image-20230429154850786

image-20230429154844437

可以看到已经生效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Abmcar

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值