Run local commands directly from the web!
localcommand.mp4
Local Command is an interface for running local commands directly from the web. It lets you use links with the cmd://
scheme, like cmd://ls -l
or any other command you want to run. It can be useful for triggering actions directly from internal dashboards.
The localcommand
program expects a string argument string starting with cmd://
followed by a URL-encoded command, for example, localcommand cmd://uname
or localcommand cmd://ls%20-l
. After registering it as a scheme handler for cmd://
, you can use cmd://
links to invoke commands form your browser. Local Command asks for confirmation before running a command, unless you define this command as pre-approved. You can configure almost everything about the way it runs: whether to run commands in a terminal (and which), how to approve running commands, and what to do with their output.
You can test Local Command by trying to run echo it worked!
here.
Local Command requires a configuration file to run. On Linux, this file will be placed under ~/.config/localcommand/config.toml
. On macOS, it's ~/Library/Application Support/localcommand/config.toml
. If you're unsure about the path in your OS, check out the xdg library, or just run Local Command and it will tell you where it expects the file.
See example.toml for configuration reference.
Obtain the localcommand
binary from the Releases page or compile it yourself.
- Place the binary in your path
- Place the desktop file in
/usr/share/applications
For Arch Linux, use the AUR package.
- Place the binary under
/Applications
git clone
the repo and copy toLocal Command.app
folder to/Applications
- If using the default config.toml, make sure to
brew install zenity
first. You might need to set your config to use/usr/loca/bin/zenity
instead ofzenity
- If the
cmd://
scheme still isn't working, trybrew install duti && duti -s org.bjesus.LocalCommand cmd
I'm not a macOS user, so if you think there's an easier way to set this up, let me know!
For Firefox, you might need to edit handlers.json
and add the following under the schemes
key:
"cmd": {
"action": 2,
"handlers": [
{
"name": "localcommand",
"path": "/usr/bin/localcommand"
}
]
},
Maybe, but I couldn't find out how. Do tell me if you find an issue! It's always a good idea to be cautious when running commands from the web. I recommend that you only use Local Command with trusted sources. If you're running the command in a terminal, I highly recommend not using sh
because it might allow running unapproved commands as approved, e.g. by calling commands like approved && unapproved
.
- Zenity - used in the example config to confirm and show commands output
- Platypus - used to wrap the binary with a macOS bundle app (whatever that is!) and register the scheme
- duti - a useful tool for selecting default applications for file types and URI schemes
This project is licensed under the MIT License.