Cmdr is an extensible and configurable script runner, that enables you to quickly execute and manage your script library.
I made cmdr to help organize and run scripts I've saved across projects and systems. These scripts are often written in different languages so I wanted a way to view and excute them all with a single command. Cmdr is lightweight, extensible, and configurable to work with most languages and runtimes.
- All your scripts organized in a central repository
- Unify multiple runtimes under the single
cmdrcommand - Manage your library with built-in commands for editing, creating, and deleting scripts
- Create your own built-in commands to extend cmdr's capabilities
To install cmdr:
- clone this repository with
git clone git@github.com:matteomiceli/cmdr.git - run
cd cmdr - run
make install - enter sudo password if prompted
Cmdr uses a config file to manage preferences and add new runtimes (located in your OS's default config location).
Unless otherwise specified in your config file, cmdr will also create a scripts directory in the user's home directory (~/scripts by default). This is where all your custom and built-in scripts will live.
Running cmdr alone will open the cli interface listing all of your custom scripts and a prompt to make a selection.
[0] get_file.py
[1] runPrettier.js
>
To call a script from the list, just enter its number and any arguments you want to pass in.
eg. > 0 www.example.com -o test.html
If you already know the name of the script you want to call, you can instead avoid the interface altogether and pass the name of the script along with any args as arguments to the cmdr function. Note: you can either call the file name (get_file) or the name including extension (get_file.py).
eg. cmdr get_file www.example.com -o test.html
Cmdr has a number of built-in commands that help you quickly manage your scripts and can be added when you start cmdr for the first time. Built-ins live in the scripts directory with all your custom scripts but are prefixed with an underscore. This means you can easily modify the code of any built-in and even write your own!
A quick way to create a new file in your scripts directory -- this will open the new file in your default editor (configured with the EDITOR environment variable).
cmdr new get_file.pyNote: when authoring cmdr scripts, you have access to the CMDR_SCRIPTS_DIR environment variable -- a string path to your scripts directory.
A quick way to edit an existing script -- this will open the new file in your default editor (configured with the EDITOR environment variable).
cmdr edit get_file.pyA quick way to delete a script.
cmdr rm get_file.pyYou can make your own built-in commands by simply prepending custom scripts with an underscore.
- Create a new script prepended with an underscore (tip: the
newsub command will create a new script in your scripts directory -cmdr new _new-built-in.sh). - Write your command (in whatever language you want) and save your changes.
- Call your new built-in with
cmdr new-built-in(built-ins are hidden from the cmdr interface and will not show up alongside your custom scripts. However, they are callable directly from the command line).