Skip to content
ocx
install

Stop typing ocx exec

The ocx exec -- prefix only wraps what you type, not what git's pre-commit hook runs. The shell hook puts the project's tools on PATH when you cd into it and takes them off when you leave. A fresh clone asks first: ocx shell allow.

Duration

Transcript

So far, every Node and pnpm command started with ocx exec.

This episode drops the prefix: cd into the project, and its tools are on PATH.

This project's pre-commit hook runs pnpm test.

With ocx exec in front, the test passes.

But on commit, git runs the hook, and the hook calls pnpm with no prefix.

Here no pnpm is found, and the commit is refused.

A laptop with its own Node and pnpm would quietly run those instead.

And a PATH exported by hand is gone in the next tab.

With the shell hook in place, you just cd into the project.

At the next prompt, OCX puts the locked tools on PATH and says so: +PATH.

Plain node now answers 26, the version in the lock.

Commit again: git starts the hook from this shell, the hook inherits its PATH, and the test passes.

Switch to the older project, which pins Node 24.

The prompt swaps the tools in one step, ~PATH, and node answers 24.

Leave both projects, and -PATH takes them off again.

The hook removes only what it added, so a directory you put on PATH yourself stays.

A fresh clone could name any registry and any tool in its ocx.toml, even one called git.

So cd changes nothing and prints one hint.

ocx shell allow is your yes; from the next prompt, the clone gets its tools.

Your own projects never asked: ocx add and ocx exec already count as consent.

ocx shell revoke takes the yes back.

The hook comes with the install.

The one-line installer ends with ocx self setup, which adds this block to your shell profiles.

Every new terminal runs it, so cd works in every tab.

On a bare binary, run that command once, then open a new terminal.

cd into a project, and its tools are on PATH for everything you start there.

A fresh clone waits for ocx shell allow.

ocx self setup puts the hook in place.

Install OCX, open a new terminal, and cd into your project.

The installer and the shell guide are at ocx.sh.

CI has no prompt for the hook.

Next: GitHub Actions, where one ocx env step sets up every later step.

Embed this video

HTML

<div style="aspect-ratio:16/9"><iframe src="https://ocx.sh/learn/videos/04-shell-hook/embed/" title="Stop typing ocx exec" loading="lazy" allow="fullscreen" style="width:100%;height:100%;border:0"></iframe></div>

MDX or JSX

<div style={{aspectRatio: '16/9'}}><iframe src="https://ocx.sh/learn/videos/04-shell-hook/embed/" title="Stop typing ocx exec" loading="lazy" allow="fullscreen" style={{width: '100%', height: '100%', border: 0}}></iframe></div>

README Markdown

[![Stop typing ocx exec](https://ocx.sh/learn/videos/04-shell-hook/light/poster.jpg)](https://ocx.sh/learn/videos/04-shell-hook/)

Duration

Transcript

Rexy has a problem.

Rexy: Every command starts with ocx exec Every. Single. Time.

Rexy: Oh no. I forgot it once.

Rexy remembers the prefix. Then he commits.

git runs the hook, and the hook runs pnpm without the prefix.

Rexy: Tiny arms! Can't reach in there.

What can he do?

Rexy: Can't the folder pick its own tools?

Bronto: Yes. Your shell can do it.

Bronto: cd in, and its locked tools are on PATH The ocx installer already set this up.

Rexy: Already? Show me!

Rexy: No prefix. Right Node.js in every folder!

Pecky clones a repo: Steggo's snack-app.

Bronto: A clone could name any tool.

Bronto: So it stays off your PATH until you say yes Pecky: It's Steggo's. I trust it.

Pecky said yes. Now cd works for Pecky too.

At your desk, just cd in.

Embed this video

HTML

<div style="aspect-ratio:16/9"><iframe src="https://ocx.sh/learn/videos/04-shell-hook/dino/embed/" title="Stop typing ocx exec" loading="lazy" allow="fullscreen" style="width:100%;height:100%;border:0"></iframe></div>

MDX or JSX

<div style={{aspectRatio: '16/9'}}><iframe src="https://ocx.sh/learn/videos/04-shell-hook/dino/embed/" title="Stop typing ocx exec" loading="lazy" allow="fullscreen" style={{width: '100%', height: '100%', border: 0}}></iframe></div>

README Markdown

[![Stop typing ocx exec](https://ocx.sh/learn/videos/04-shell-hook/dino/poster.jpg)](https://ocx.sh/learn/videos/04-shell-hook/#dino)