Ask LLM Instantly in terminal
  • PowerShell 56.7%
  • Shell 43.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-08 22:49:16 +08:00
ai.ps1 ai.sh使用方式同步ai.ps1 2026-08-08 22:49:16 +08:00
ai.sh ai.sh使用方式同步ai.ps1 2026-08-08 22:49:16 +08:00
README.md ai.sh使用方式同步ai.ps1 2026-08-08 22:49:16 +08:00

ai

一个命令行 AI 助手,在终端里快速调用 LLM。

文件

文件 适用平台 使用方式
ai.sh Linux / macOS / WSL ./ai.sh <提问>
ai.ps1 Windows (PowerShell) ./ai.ps1 <提问> 或设为模块导入

前置依赖

  • curl(仅 ai.sh 需要)
  • jq(仅 ai.sh 需要)
  • API 密钥(需自行填入脚本)

可选增强

  • glow — 终端内渲染 Markdown(表格、代码块等)
  • mermaid-ascii — 将 ```mermaid 图表块渲染为 ASCII 字符图

配置

编辑脚本,填入以下内容:

apiKey="你的密钥"
model="你的模型名"  # 如 gemini-3.6-flash-tiered 等
apiBase="https://api.openai.com/v1/chat/completions"  # 你的API地址

PowerShell 版本在 ai.ps1 顶部的 # --- 配置区 --- 中填写。

用法

直接提问

# Bash
ai 用 Python 写一个快速排序

# PowerShell
.\ai.ps1 用 Python 写一个快速排序

管道输入

# Bash
cat code.py | ai 何意味

# PowerShell
Get-Content code.py | .\ai.ps1 何意味

结合参数与管道

# Bash
git diff | ai 生成 commit message

# PowerShell
git diff | .\ai.ps1 生成 commit message

特性

  • Mermaid 图表渲染:当回答包含 ```mermaid 代码块时,会自动提取并渲染为 ASCII 字符图,并将原文中的图表块替换为 > **图 N 见文末** 引用标记。
  • Markdown 渲染:配合 glow 可在终端中显示格式化后的 Markdown 内容。
  • 单次对话:每次调用为独立会话,无历史记忆。