on main help sign in
docs(hooks): clarify relative paths
1d42341Kieran Klukas
docs/hooks/README.md+25−1
@@ -44,7 +44,9 @@ disallow the use of Haskell (but we love you, Simon Peyton Jones).
44### Config
44### Config
45
45
46The first thing we need to do is hook up our hook. Let's add the following to
46The first thing we need to do is hook up our hook. Let's add the following to
47−our local `crush.json`. You can, of course, do this globally, too.
47+our **project-level** `crush.json`. Relative paths like `./no-haskell.sh` work
48+here because the project root is your working directory. If you're configuring
49+a global hook (`~/.config/crush/crush.json`), use an absolute path instead.
48
50
49```jsonc
51```jsonc
50{
52{
@@ -146,6 +148,28 @@ and project-level, with project level hooks taking precedence.
146}
148}
147```
149```
148
150
151+> [!IMPORTANT]
152+> The `command` is resolved relative to your **current working directory** —
153+> not relative to the config file. Relative paths like `./hooks/whatever.sh`
154+> work fine in project-level `crush.json` because the project root is also
155+> your working directory. For **global** config (`~/.config/crush/`),
156+> however, you must use either an absolute path or an inline command:
157+>
158+> ```jsonc
159+> // Global ~/.config/crush/crush.json
160+> {
161+> "hooks": {
162+> "PreToolUse": [
163+> {
164+> "command": "/home/you/.config/crush/hooks/no-haskell.sh"
165+> // or use an inline command:
166+> // "command": "echo '{\"decision\":\"allow\"}'"
167+> }
168+> ]
169+> }
170+> }
171+> ```
172+
149Remember, hooks will run in parallel but resolve in config order. Last hook
173Remember, hooks will run in parallel but resolve in config order. Last hook
150wins when rewriting input, but first deny wins when blocking.
174wins when rewriting input, but first deny wins when blocking.
151
175