A zsh widget that generates commands from natural language using lms.
Type what you want to do in plain English, and zshguy asks the model for a zsh command or an insertion at the cursor position.
zshonlylmscommand from LM Studio- LM Studio must be started once and finish its first-run setup before
lmswill work reliably
Run these steps before using the widget:
# Check LMS CLI availability
lms --help
# Confirm LM Studio is running and the model is reachable
lms chat -p "ping"If you set ZSHGUY_MODEL, run lms chat "$ZSHGUY_MODEL" -p "ping" instead.
qwen/qwen3.5-9b is an example model name. Replace it with the model key you want to use.
When preparing a new environment, run once:
# Download model
lms get qwen/qwen3.5-9b
# Confirm local model key
lms ls
# Load model to memory
lms load qwen/qwen3.5-9b
# Verify generation
lms chat qwen/qwen3.5-9b -p "ping"If you omit the model/key argument for lms get or lms load, LM Studio opens an interactive selector.
Add zshguy to your plugins.toml and let sheldon load the canonical plugin entrypoint:
[plugins.zshguy]
github = "hokupod/zshguy"Use zshguy.plugin.zsh as the canonical plugin entrypoint:
source /path/to/zshguy.plugin.zshzshguy.sh remains available as a compatibility path for manual sourcing and older setups.
If you do not use a plugin manager, source the compatibility wrapper from your .zshrc:
source /path/to/zshguy.shzshguy does not bind a key automatically. Add a manual bindkey mapping:
bindkey '^X^J' zshguy-widgetOther examples:
bindkey '^X^J' zshguy-widget
bindkey '^X^G' zshguy-widgetPress your bound key, then enter a prompt at the [zshguy] prompt.
If the command line is empty, zshguy generates a full zsh command.
Example prompt:
count the number of files in the current directory
If you already have text on the command line, zshguy inserts text at the cursor position.
Example buffer:
git checkout
Example prompt:
main
If the prompt is empty or generation fails, the current buffer stays unchanged.
Set ZSHGUY_MODEL to choose a different LM Studio model name:
export ZSHGUY_MODEL=llama-3.1-8b-instructIf ZSHGUY_MODEL is unset, lms chat uses its default model.
To inspect model output rejected by validation, enable debug mode:
export ZSHGUY_DEBUG=1When validation fails, zshguy will print the raw output and normalized output to stderr.
MIT
hokupod
Originally based on bashguy by Yasuhiro Matsumoto (a.k.a. mattn).