macOS 用户装 xh 比 Linux 还简单,Homebrew 一个命令搞定。如果你用的是 Apple Silicon(M1/M2/M3)或 Intel,都能直接跑。nn


nn

Homebrew(推荐)

nnHomebrew 是 macOS 最流行的包管理器,xh 在主仓库里:nn

Bash
brew install xhn

nn装完验证:nn

Bash
xh --versionn

nn


nn

MacPorts

nn如果你用 MacPorts:nn

Bash
sudo port install xhn

nn


nn

安装脚本(通用)

nn不想用包管理器?一条命令搞定:nn

Bash
curl -sfL https://raw.githubusercontent.com/ducaale/xh/master/install.sh | shn

nn装到 $HOME/.local/bin/ 下,然后:nn

Bash
export PATH="$HOME/.local/bin:$PATH"nxh --versionn

nn可以把上面那句加到 ~/.zshrc~/.bash_profile 里永久生效。nn


nnxh macOS Homebrew 安装与测试nn

下载二进制

nn去 Release 页面 找 macOS 版本:nn

Bash
VERSION=$(curl -s https://api.github.com/repos/ducaale/xh/releases/latest | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4)ncurl -LO "https://github.com/ducaale/xh/releases/download/${VERSION}/xh-${VERSION}-x86_64-apple-darwin.tar.gz"ntar -xzf xh-*.tar.gzn# 移到 PATH 里nmv xh /usr/local/bin/nxh --versionn

nn

n Apple Silicon Mac 用户找 aarch64-apple-darwin 版本;Intel Mac 找 x86_64-apple-darwin。n

nn


nn

和 Linux 版共存

nn如果你和我一样,Linux 服务器和 macOS 本机都要用 xh,可以把二进制下载下来丢进 PATH,Homebrew 和系统命令互不干扰。nn


nn

Apple Silicon vs Intel

nn

n n n

n

n

n

n

n n

n

n

n

n

n

n

n

n

芯片 下载架构
Apple M1/M2/M3/M4 aarch64-apple-darwin
Intel Mac x86_64-apple-darwin

nn用 uname -m 可以确认:nn

Bash
uname -mn# arm64  → Apple Siliconn# x86_64 → Inteln

nn


nn

快速上手

nn

Bash
# GET 请求nxh https://httpbin.org/jsonnn# POST 带 JSONnxh post https://httpbin.org/post name=macos age:=4nn# 查看帮助nxh --helpn

nnmacOS 自带 zsh,tab 补全可以用 Homebrew 提供的:nn

Bash
# Homebrew 自动配置补全nbrew install xh  # 完成后会提示如何启用n

nn


nn

总结

nn

n n n

n

n

n

n

n n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

方式 命令
Homebrew(推荐) brew install xh
MacPorts sudo port install xh
安装脚本 curl -sfL .../install.sh | sh
手动二进制 Release 页面下载对应架构版本

nnmacOS 安装比 Linux 简单多了,基本不需要操心依赖问题。xh 的 macOS 版打包得很好,装完直接用。nn英文版介绍和使用指南也在路上了,有兴趣的可以等后续。

最后修改: 2026年7月6日

作者