1. 介绍
是否每次被这样英文的 命令行 help,吓得打开搜索引擎去看文档,然后就打断了你的节奏 😤
来吧,废话少说我们直接上效果
输入npm --help 后面加上 | aicn AI 将会帮你翻译成中文
2. 安装与配置aichat
aichat 是一款 命令行AI工具,他支持许多平台的AI,这里我将安装 aichat 并配置 OpenAI Key 来为我们提供 翻译
2.1 安装
对于 macOS Homebrew 或 Linuxbrew 用户
brew install aichat
对于 Windows Scoop 用户
scoop install aichat
其他安装方式查看 官方文档 Install
2.2 配置
首次启动时,aichat 将引导您完成 配置。
# 没有配置文件,创建一个新的?是的
> No config file, create a new one? Yes
# 选择ai平台(这是我是选择openai)
> AI Platform: openai
# 填写你的 api key
> API Key: <your_api_key_here>
2.3 如果你使用了第三方openai
Tip:使用官方 OpenAI KEY 的朋友请跳过这步
- 查看
aichat配置文件地址
aichat --info
这里复制出来的路径中 /Application Support 带了空格 ,你需要加上\ 来转义空格,如:
/Users/Username/Library/Application\ Support/aichat/config.yaml
- 配置 config.yaml
添加 api_base,注意如果你的地址后面没有 /v1 你需要自己补充上去
model: openai:gpt-3.5-turbo
clients:
- type: openai
api_key: # 你的 api key
api_base: # 你的 api 地址,如 https://openkey.cloud/v1
2.4 配置aicn 别名
这一步是为了 简化命令,使我们可以通过 | aice 来 调用翻译
- 编辑
~/.zshrc追加配置别名
# ai
alias ai="aichat"
alias aicn="ai translate to chinese"
- 执行
source使.zshrc配置生效
source ~/.zshrc
3. 使用
只要你在命令后面加上 | aicn 你将可以翻译任何命令的输出, 输入命令来试试吧
查看 npm 中文帮助
npm --help | aicn
查看 git 中文帮助
git --help | aicn
查看 npm 中文帮助手册
man npm | aicn