A Universal Terminal alias for bun, pnpm, npm, and yarn
I’ve typed npm for the last time.
Below is zsh function that I’ve used to eliminate package manager context switching heartache — typing
npm start when I meant
bun start or
npm when I mean ::shudders::
zsh functions can be used like fancy aliases with the addition of a runtime check. This function checks for the existence of a lock file and runs the stated command with the correct package manager.
This function does not create a universal interface around the varied package managers. I don’t find universal interfaces helpful.
And I enjoy utilizing the subtleties in each package manager. My problem is the muscle memory around common commands (
test) and those actions inadvertently spawn confusion.
Check out these references if you want to learn more about zsh functions.