Stop replacing
by hand.

Paste the command exactly as the README wrote it. Your shell can intercept npx and run pnpm dlx instead.

Step 1 - Open your shell config

Since you're using Zsh, the file you're looking for is:

Step 2 - Paste this function

Add the following to the bottom of .zshrc. Yes, the whole thing.

function npx() {
  pnpm dlx "$@"
}

What does "$@" mean? It passes every argument you typed along to pnpm dlx. You're welcome.

Step 3 - Reload your shell

The file doesn't reload itself. Run this:

source ~/.zshrc

Or just open a new terminal tab like a normal person.

Step 4 - Verify it works

npx cowsay "I use pnpm now"

If a cow says it, it's true.

Too lazy? Give this to your AI

Can't be bothered to do four whole steps? Fine. This prompt is already tailored to Zsh - just copy and paste it.

Prompt

I want to set up a shell function that redirects npx to pnpm dlx. I'm using Zsh, so my shell config file is ~/.zshrc. Here's what to do: 1. Open ~/.zshrc. 2. Add the following function at the bottom of that file: function npx() { pnpm dlx "$@" } 3. Save the file. 4. Reload the config by running: source ~/.zshrc 5. Confirm the override is active by running: which npx - it should be a shell function, not a binary. Don't overthink it.

That's it. Four steps. You've earned a coffee. by Dafnik