pkgx.sh
The last program you will install.
Woohoo! Hello, everyone. I just found the new command-line tool - pkgx from the creator of Homebrew. Pkgx is an standalone command-line tool that allows you to run any program like `npx` in node.
For example, if you want to run node program in your system normally you would do something like this.
brew install node
node run index.jsRight? but if you use the Pkgx you can just
pkgx node run index.jsPkgx will find node → download → run for us. Isn’t that great? You also can declare the dependencies for the project like virtualenv for python for any project with `.pkgx.yaml`
# .pkgx.yaml
dependencies:
nodeand run another command from pkgx - `dev` that will add the all the necessary command-line tools that we declared in the yaml file to that terminal session.
We can also combine this with a shell script that will increase portability of our script to the max. For example, if you want to use `gum` command but you do not know whether your user will have `gum` installed or not. You can do something like this.
#!/bin/sh
if ! hash pkgx 2>/dev/null; then
eval "$curl -Ssf https://pkgx.sh)"
fi
pkgx node run index.jsThis script will download the pkgx to the /tmp folder, then run the program that we want. When we leave the session, the program will be deleted by the system. That means anyone with the internet can run the program. COOL!!


