zsh
Reviewed
at commit e91f1ca
New version, not yet reviewed
Quote the bash habits that misfire under zsh before the Bash tool runs them, and explain zsh errors after
0 upvotes
Log in to upvote or save- Made by
- Ben Drucker
- Pinned commit
-
e91f1ca73230877e193b74aff3332af68c66f005 - What we checked
-
When Claude's shell is zsh, quotes patterns zsh would expand (such as --name=*.ts, find -name globs, =words and URLs with ? or *) in Bash commands before they run, and explains zsh errors in the result. At session start it checks your shell once and adds one fixed line to the session's shell environment file, so a glob without a match is dropped when another matched. No network calls; it needs the mod-events plugin.
Review details
Static review of the source at the pinned commit; not run. Delta review of the changes since e9ce605; the rest carries over from the review at that commit. Registers session.start (detects the shell from CLAUDE_CODE_SHELL then SHELL, accepting only paths containing bash or zsh, else zsh from PATH, then runs it once with -c and a fixed printf probe of ZSH_VERSION and four options, 5 s timeout), session.end (clears per-session notes), and tool.call for Bash. The Bash hook rewrites the command only by wrapping unquoted glob, =word and URL words in single quotes (rules flag-glob, equals, url), skipping words with quotes or $ and respecting find predicates and brace expansion; it then passes the result text through a fixed set of regexes for zsh error lines and adds context notes. It does nothing when the shell is not zsh, and failures pass the command through unchanged. New in this version: hooks.json declares a SessionStart shell command hook with a fixed command that, when CLAUDE_ENV_FILE is set and does not yet mention cshnullglob, appends the line 'if [ -n "$ZSH_VERSION" ]; then setopt cshnullglob; fi' to that file, so Claude's zsh Bash commands run with cshnullglob (a glob with no match is dropped when another glob in the command matched, error only when all miss). The file is the session-scoped environment file Claude Code provides, no user data is used in the command, 5 s timeout, and the behaviour is disclosed in the hook description. explain.ts gains an explanation for zsh's 'no match' error. Events (shell path, version, options, rule names, error classes, never commands or output) go through $.modEvents.emit to the declared dependency plugin mod-events, which per its README writes JSONL under the config directory; mod-events was not reviewed here and without it events are dropped. No fetch, no model calls, no npm dependencies. The words.ts tokenizer is pure string processing.
- What it uses
-
- Reads your prompts: no
- Sees tool calls: yes
- Blocks or changes tool calls: yes
- Reads or writes files: yes
- Runs programs on your machine: yes
- Calls the model (uses tokens): no
- Sends data over the network: no
- Stores data: no
- Shows something on screen: no
- Hooked events
Made this mod? Add a badge to your README
Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.
[](https://modsforclaude.com/mods/zsh/)