Pronounced as Bacon. An attempt to create a simplified Make and Makefile for running commands.
This is a simple program that allows you to run commands from a YAML file. This is useful for running commands that you run often but don't want to remember the syntax for, especially in pipelines.
- AMD64 Linux
- CD to the
bindirectory. - Run
./bknfrom this directory or copy thebknbinary and thebkn.yamlto another directory. - Update the bkn.yaml file with your commands.
By default bkn reads bkn.yaml from the current working directory. Use -c / --config (see Flags) to point it at a YAML file in another location instead of copying one next to the binary.
| Flag | Description |
|---|---|
-c, --config <path> |
Path to the YAML file to load. Defaults to bkn.yaml in the current working directory. |
-h, --help |
Print colored usage info and the list of available commands, then exit. |
Both short and long forms accept the standard Go-flag spellings: -c path, -c=path, --config path, and --config=path all work.
Examples:
# Run the `hello` command from a YAML file in another directory
bkn -c /etc/bkn/team.yaml hello
# Forward args to the underlying shell command (positional args after the command name)
bkn --config ~/dotfiles/bkn.yaml greet Ed
# Show help with the command list
bkn --helpNote: because flag parsing uses Go's standard flag package, -c / -h are consumed wherever they appear on the command line. If you need to forward a literal -c or -h to your shell command, quote it or rename the conflicting argument.
- Install Golang
- Clone the repo
- CD to the repo directory
- Run
go build -o bin/bkn ./cmd/bkn - Run
go test ./...to execute the test suite
The YAML file is used to define the commands that you want to run. The file should be named bkn.yaml and should be in the same directory as the bkn binary.
Example:
include: # Optional. Include other YAML files to keep your commands organized.
- /path/to/other/file.yaml
commands:
- name: list # The name of the command
description: List the contents of the directory. # The description of the command
command: |- # The command to run. The |- allows for multiline commands in a YAML file
ls -lah "$@"
- name: listening
description: List all programs listening on a given port
command: |-
ss -tupln | grep LISTENAny arguments after the command name are forwarded to the shell as positional parameters, just like a bash script. Reference them in your YAML command with $1, $2, $3, …, or use $@ to expand all of them.
For example, given the list command above:
./bkn listrunsls -lahwith no arguments../bkn list /tmprunsls -lah /tmp../bkn list /tmp /varrunsls -lah /tmp /var.
You can also pull individual positions, e.g. command: echo "first=$1 second=$2".
