How To Use — 输入命令名,AI 告诉你用法。
查询 Linux 命令的用法(tar, find, git, docker 等),调用本地 Ollama 模型流式输出答案,支持联网搜索增强。
# 1. 安装依赖
pip install -r requirements.txt
# 2. 确保 Ollama 正在运行
systemctl --user start ollama
# 3. 使用
python htu.py tarpython htu.py <命令> [选项]| 参数 | 说明 |
|---|---|
query |
要查询的命令(必填) |
| 选项 | 默认值 | 说明 |
|---|---|---|
-n, --no-search |
— | 禁用联网搜索,仅用模型知识 |
-m, --model |
codellama:7b |
Ollama 模型名 |
--ollama-url |
http://localhost:11434 |
Ollama 服务地址 |
# 查询 tar 命令用法(联网搜索增强)
python htu.py tar
# 查询带空格的命令
python htu.py "git commit"
# 仅用模型知识,不联网
python htu.py curl -n
# 指定模型
python htu.py find -m llama3.2:3b
# 使用远程 Ollama
python htu.py docker --ollama-url http://192.168.1.100:11434将脚本设为可执行并加到 PATH 中:
chmod +x htu.py
# 方法 A: 软链到 ~/.local/bin(推荐)
ln -s "$(pwd)/htu.py" ~/.local/bin/htu
# 方法 B: shell alias(加到 ~/.bashrc)
echo "alias htu='python3 $(pwd)/htu.py'" >> ~/.bashrc
source ~/.bashrc之后直接用:
htu tar- Python 3.8+
requests- 本地运行的 Ollama(带可用模型如
qwen3:8b)
qwenconnent/
├── htu.py # 主脚本
├── requirements.txt # Python 依赖
├── .gitignore
└── README.md