Skip to main content

AutoSH — 一句中文,自动补命令

Project description

AutoSH / ah

AutoSH logo

stars python zsh bash license updated

卧槽,命令忘了怎么办!

别急:一句中文,秒出命令

AutoSH(ah)是给中文程序员的终端 AI 助手。在 zsh 里写中文,按一下就出命令。

天下苦 Bash 久已,快来 ah 一下。

两种模式

快捷键 模式 效果
Ctrl+/ 极速 直接出命令,一步到位
Ctrl+Shift+/ 选择 弹出三个候选 + 中文解释,看懂了选

/? 是同一个键,所以 Ctrl+Shift+/ = 按住 Ctrl+Shift 再按 /

$ docker 清理无用镜像         # ← 在终端里直接写中文
# 按 Ctrl+/ → 直接变成:
$ docker system prune -f      # ← 回车就跑

安装

一键安装:

curl -fsSL https://wang-h.github.io/autosh/install.sh | bash

从 GitHub 安装:

uv tool install git+https://github.com/wang-h/autosh.git
# 或: pip install git+https://github.com/wang-h/autosh.git

然后配 Key + 切模型 + 注入 Shell:

ah config set api_key <your-api-key>
ah config set provider deepseek   # 支持: kimi / minimax / qwen / glm
ah init zsh                       # 或 ah init bash
source ~/.zshrc

装完就可以在终端里用了——zsh 和 bash 都支持ah init 会自动识别。

使用

装完就能用,zsh 和 bash 都行。直接在终端里写中文,按快捷键:

# Ctrl+/ → 极速,直接出
$ docker 清理无用镜像        # 你写的
$ docker system prune -f     # ah 替换的,回车就跑

# Ctrl+Shift+/ → 三选一,带解释
$ git 回退上一次提交
  [1] git reset --soft HEAD~1  撤销提交但保留修改
  [2] git reset --mixed HEAD~1  撤销提交和暂存
  [3] git revert HEAD           生成新提交来撤销
  Pick [1-3]:                  # 回车默认选 1

命令

命令 说明
ah init <zsh|bash> 安装 Shell 集成
ah config 查看当前配置
ah config set <key> <value> 设置配置项(切 provider 一键切模型)
ah suggest <中文描述> 直接生成命令建议
ah doctor 检查环境配置

配置

~/.autosh/config.yaml

provider: deepseek
model: deepseek-v4-flash
base_url: https://api.deepseek.com/anthropic
api_key: sk-xxx
配置项 说明
provider AI 提供商:deepseek / kimi / minimax / qwen / glm
model 模型名称(切 provider 自动更新)
base_url API 地址(切 provider 自动更新)
api_key API 密钥
ah config set provider kimi      # 切到 Kimi
ah config set provider deepseek  # 切回来

自定义快捷键

编辑 ~/.autosh/autosh.zsh

# 极速模式(bindkey '^_'  = Ctrl+/)
bindkey '^_' autosh-fast

# 选择模式(bindkey '^?' = Ctrl+Shift+/)
bindkey '^?' autosh-pick

原理

读取当前命令行缓冲区 → 发送给 AI API → 模型生成命令 → 替换回命令行。不上传命令历史。

环境要求

  • Python 3.11+
  • zsh 或 bash
  • 任一提供商 API Key(DeepSeek / Kimi / MiniMax / Qwen / GLM)

Star History

Star History Chart

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autosh_ah-0.1.0.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autosh_ah-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file autosh_ah-0.1.0.tar.gz.

File metadata

  • Download URL: autosh_ah-0.1.0.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for autosh_ah-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b1637e87e9c681a7238c903e0ebccd2f7d62dd3a1c0a3ff4c1dcd4fe6a7c612b
MD5 5ccdcaa43f7066887fc6a85f67c17724
BLAKE2b-256 653676aa07df21d708426d7d9a3f70c360700c1dd88dfdf90126a549d018fb62

See more details on using hashes here.

File details

Details for the file autosh_ah-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: autosh_ah-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for autosh_ah-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46375780284479063ca7baa0201a866920dabe030ba6fbdbde16846043f19ed9
MD5 2af56bdbe830f7fc0e2123d6da5b3112
BLAKE2b-256 fc0e17f3c8e002e0dd4791d2046251b9b33ae7c7f491becbb6df2652ac7f892d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page