Crates.io | multiconf |
lib.rs | multiconf |
version | 0.1.11 |
source | src |
created_at | 2022-02-09 04:42:19.385884 |
updated_at | 2022-02-12 13:09:38.515485 |
description | Easily generate different versions of config files |
homepage | |
repository | https://github.com/sanity/multiconf |
max_upload_size | |
id | 529488 |
size | 54,441 |
A command line tool for easily generating multiple versions of a configuration file from a single template.
I'm a big fan of the i3 window manager, and I use it on several linux desktops and laptops. While I mostly want the same i3 configuration across all of these computers, some require different variations.
I created multiconf to make it easy to generate multiple variations of a config file.
$ curl https://sh.rustup.rs -sSf | sh
$ cargo install multiconf
Create a file called base.txt
:
global config 1
global config 2
dog$>>canine config 1
cat$>>feline config 1
global config 3
Then create dog.txt
from base.txt
:
$ multiconf --choice dog --input base.txt --output dog.txt
This will contain:
global config 1
global config 2
canine config 1
global config 3
If you want dog.txt to be automatically updated every time base.txt changes, use:
$ multiconf --choice dog --input base.txt --output dog.txt --watch
Here is the line I use in my i3 config so I can have different versions depending on the hostname of the computer:
exec --no-startup-id multiconf \
--choice `hostname` \
--input ~/Dropbox/code/linux-cfg/i3/config \
--output ~/.config/i3/config \
--watch
Here are some example lines from my i3 config, which I share between machines using Dropbox:
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
technic$>>font pango:DejaVu Sans Mono 12
pocket$>>font pango:DejaVu Sans Mono 16
framework$>>font pango:DejaVu Sans Mono 15
technic
, pocket
, and framework
are the hostnames of my three linux computers.
multiconf [version]
Easily generate different versions of config files
USAGE:
multiconf [OPTIONS] --choice <CHOICE>
OPTIONS:
-c, --choice <CHOICE> The selected
-h, --help Print help information
-i, --input <INPUT> The input file, or stdin if not specified
-o, --output <OUTPUT> The output file, or stdout if not specified
-s, --separator <SEPARATOR> Separates choice from the line chosen [default: $>>]
-V, --version Print version information
-w, --watch Watch the input file for changes and update the output file when
it does