lov-zsh-alias
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese终端快捷指令 · Shell Shortcuts
终端快捷指令 · Shell 快捷指令
Append a zsh alias or function to behind sentinel markers, so
re-running updates the entry in place instead of duplicating it. Works for
both English () and 中文 () trigger names.
~/.zshrczxsd中信书店在 的 sentinel 标记范围内追加 zsh alias 或 function,
因此重复运行时会原地更新该条目,而不是创建重复项。英文()和中文
()触发名称均可使用。
~/.zshrczxsd中信书店When to Use
何时使用
- User wants to bind a trigger word to a shell command ("我输入 X 就跑 Y")
- User wants a 中文 trigger ("输入'中信书店'就启动 claude 说一句开心话")
- User wants multiple aliases pointing to the same command
- User wants to remove a previously-added alias
Do NOT use for:
- System-level shortcuts that need to fire without pressing Enter — that's an input-method or Hammerspoon job, not a shell alias. Tell the user.
- Non-zsh shells unless they explicitly pass .
--rcfile
- 用户希望将触发词绑定到 shell 命令(“我输入 X 就跑 Y”)
- 用户希望使用中文触发词(“输入'中信书店'就启动 claude 说一句开心话”)
- 用户希望创建多个指向同一命令的 alias
- 用户希望移除之前添加的 alias
不适用于:
- 无需按 Enter 即可触发的系统级快捷键——这属于输入法或 Hammerspoon 的范畴, 而不是 shell alias。请告知用户。
- 非 zsh shell,除非用户明确传入 。
--rcfile
Workflow (MANDATORY)
工作流(必须执行)
Step 1: Ask the user (only what's missing)
步骤 1:向用户询问(仅询问缺失信息)
Use to collect anything not already obvious from context.
Typical fields:
AskUserQuestion- Trigger name(s): the word(s) the user types. Multiple OK.
- Command: the shell command to run. Quote carefully.
- Style:
- (default) — supports CJK names, supports passing args via
function"$@" - — only for ASCII names; uses
simple aliasformalias name='cmd'
If the user already gave the trigger + command in plain language ("中信书店
→ 启动 claude 说一句开心话"), skip the question and proceed.
使用 收集上下文中尚不明确的信息。
常见字段:
AskUserQuestion- 触发名称:用户输入的词语。可以提供多个。
- 命令:要运行的 shell 命令。注意正确引用。
- 样式:
- (默认)——支持 CJK 名称,支持通过
function传递参数"$@" - ——仅适用于 ASCII 名称;使用
simple alias形式alias name='cmd'
如果用户已经用自然语言提供了触发词和命令(“中信书店
→ 启动 claude 说一句开心话”),则跳过提问并继续执行。
Step 2: Dry-run preview
步骤 2:试运行预览
bash
python3 scripts/add_alias.py \
--name <trigger> \
--cmd '<shell command>' \
--comment '<one-line explanation>' \
[--also-as <other-trigger>] \
--dry-runShow the rendered block to the user.
bash
python3 scripts/add_alias.py \
--name <trigger> \
--cmd '<shell command>' \
--comment '<one-line explanation>' \
[--also-as <other-trigger>] \
--dry-run向用户展示渲染后的代码块。
Step 3: Apply
步骤 3:应用
Re-run without . The script writes a sentinel-wrapped block to
. Re-running with the same updates in place.
--dry-run~/.zshrc--name重新运行同一命令,但去掉 。脚本会将带 sentinel 标记的代码块写入
。使用相同的 重新运行时会原地更新条目。
--dry-run~/.zshrc--nameStep 4: Tell the user to reload
步骤 4:告知用户重新加载
bash
source ~/.zshrcThen they can type the trigger + Enter.
bash
source ~/.zshrc随后用户可以输入触发词并按 Enter。
Removing an alias
移除 alias
bash
python3 scripts/add_alias.py \
--name <trigger> --cmd unused --removebash
python3 scripts/add_alias.py \
--name <trigger> --cmd unused --removeCLI Reference
CLI 参考
| Argument | Default | Description |
|---|---|---|
| (required) | Trigger word; ASCII or 中文 |
| (required) | Shell command to run |
| none | Extra alias name(s); repeatable |
| empty | Comment line above the block |
| off | Use |
| | Target rc file |
| off | Print, don't write |
| off | Remove the entry for |
| 参数 | 默认值 | 说明 |
|---|---|---|
| (必填) | 触发词;支持 ASCII 或中文 |
| (必填) | 要运行的 shell 命令 |
| 无 | 额外的 alias 名称;可重复使用 |
| 空 | 代码块上方的注释行 |
| 关闭 | 使用 |
| | 目标 rc 文件 |
| 关闭 | 仅打印,不写入 |
| 关闭 | 移除 |
Block Format
代码块格式
Each entry is wrapped in sentinel markers so the script can find and update
it on re-run:
undefined每个条目都由 sentinel 标记包裹,因此脚本可以在重复运行时查找并更新它:
undefined>>> lov-zsh-alias >>> <name>
>>> lov-zsh-alias >>> <name>
<comment>
<comment>
<name>() { <cmd> }
<also-as>() { <name> "$@" }
<name>() { <cmd> }
<also-as>() { <name> "$@" }
<<< lov-zsh-alias <<< <name>
<<< lov-zsh-alias <<< <name>
undefinedundefinedNotes for Claude
Claude 注意事项
- zsh supports CJK function names natively — no quoting trickery needed.
- shell aliases ALWAYS require pressing Enter. If the user expects "auto fire on typing", clarify upfront — they need an input method shortcut or Hammerspoon, not this skill.
- Don't for CJK names; the script will reject it.
--simple - The user must (or open a new terminal) to pick up the new alias. Always say so after writing.
source ~/.zshrc
- zsh 原生支持 CJK function 名称,无需使用引号规避技巧。
- shell alias 始终需要按 Enter。如果用户期望“输入时自动触发”,应提前说明—— 他们需要输入法快捷键或 Hammerspoon,而不是此 skill。
- CJK 名称不要使用 ;脚本会拒绝该操作。
--simple - 用户必须执行 (或打开新终端)才能加载新 alias。 写入后务必告知用户。
source ~/.zshrc
User Configuration
用户配置
Set to change the default rc file.
still takes precedence.
SKILL_ZSH_ALIAS_RCFILE--rcfile设置 可更改默认 rc 文件。
仍具有更高优先级。
SKILL_ZSH_ALIAS_RCFILE--rcfileRuntime context (shared)
运行时上下文(共享)
运行前读取本 Skill 包的 ,由宿主提供 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。
skill.yamlskill-runtime/v1- 只使用 Manifest 声明的字段;Profile 保存公开品牌事实,Preferences 保存个人工作偏好。
- 字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。
required: true - 报错提供可复制的 、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。
context_id
运行前读取本 Skill 包的 ,由宿主提供 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。
skill.yamlskill-runtime/v1- 只使用 Manifest 声明的字段;Profile 保存公开品牌事实,Preferences 保存个人工作偏好。
- 字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。
required: true - 报错提供可复制的 、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。
context_id