| conf.example.lua | initial commit | |
| COPYING | initial commit | |
| main.lua | initial commit | |
| README.md | initial commit | |
My
Wrap infrequently used scripts to aid memory.
TODO
- Add support for variadic arguments. For example, passing as many files to
grepas you want. Shell globbing won't work as desired until this is done.
Examples
$ my
(my ?) Enter command: echo
(my) Found the following configurations for echo:
(my) INDEX: DESCRIPTION
(my) test: Test `my` by printing some things.
(my ?) Enter index: test
(my) Found "test" configuration for echo. Description: Test `my` by printing some things.
(my) Preset arguments: plecostomus
(my ?) What else would you like to print? 'is a species of fish'
(my) Running command line: echo plecostomus 'is a species of fish'
plecostomus is a species of fish
$
The above implies a configuration file something like the following.
conf.lua:
return {
echo = {
test = {
description = 'Test `my` by printing some things.',
args_pre = { 'plecostomus' },
args_now = { 'What else would you like to print?' },
},
},
}
The following invocation runs the same command as the first:
$ my echo:test 'is a species of fish'
Installation
my is standalone pure Lua. The file includes a shebang line already. If there's a lua in your path, all you need to do is make main.lua executable, write a configuration file, and run.
Usage
usage: my cmd[:index] arg...
cmd specifies the command to run. index specifies which configuration to use for that command. Arguments follow. my will prompt for anything not found on the command line.
The configuration file defines the commands and configurations available.
Configuration
See conf.example.lua. my expects $XDG_CONFIG_HOME/my/conf.lua, or as a fallback, $HOME/.config/my/conf.lua.
The configuration file must return a Lua table. The top level table maps commands (as you'd type them on the command line) to tables. Those tables, in turn, map indices to tables. Those tables must contain a description field and may also contain args_pre and args_now fields.
description: String. Printed to remind you which configuration this index describes.args_pre: List of strings. Preset arguments that always appear in the final command line.args_now: List of strings. Prompts that are asked in turn to request any arguments not supplied on the command line.