Simple dotfile pre-processor with a per-file configuration

Overview

ix

(eeks) Simple dotfile pre-processor with a per-file configuration



Summary (TL;DR)

  • ix.py is all you need
  • config is an ini file.
  • files to be processed must contain #: ix-config within the first 20 lines.
  • more options can be specified per file after the #: ix-config.
  • variables to be processed are defined as follows #{{ section.variable }}.
  • default config directory ~/.config/ix/ixrc (overwrite with -c)
  • default parse directory ~/dots (overwrite with -d)
  • full docs here



The Long Version

What?

pre-processor: a program that processes its input data to produce output that is used as input to another program.

This is a tool that allows you to define placeholders within your files (such as ${{ colors.background }}) and then have them replaced with a value you've defined somewhere else whenever you please. Allowing you to stay worryless about where that value might be stored since you know it can only be stored in one place: ixrc.




Why?

I've always had a lot of environment variables scattered all around the place. It's hard to keep track of everything in this way.

ix is an attempt at simplifying all of that by providing a single, central file that contains every single variable you might think of, or would need: colors, paths, editor, etc. All defined and controlled by you.

Aside from that, it also provides some nifty addons on top of the normal "find and replace" behaviour to allow you to customise exactly what happens to each file it reads, giving you even more control and structure.




How does it work?

There's a total of 2 pieces to the puzzle:

  1. The configuration that contains everything. By default ix will look for it in ~/.config/ix/ixrc but can be easily overwritten with the -c flag.
  2. The actual preprocessor script, the python file.

When you run the script, it'll assume everything you want to parse is in ~/dots, which is probably wrong so you'll want to overwrite that. You can do that with the -d flag and specifying a new path.

ix will recursively read through the given directory and find any files that contain the ix declaration (which looks like this #: ix-config). Basically a comment followed by a colon. This //: works too, and this /*:, even this --:. If it doesn't work, then it can be added.

Note that the definition needs to be within the first 20 lines of the file otherwise ix will ignore that file.

The lines after the definition can contain more information about how ix should handle this specific file. These are the simple addons I mentioned earlier. For example:

#: ix-config
#: to: /etc/whatever/

...
Check the full list of available options in the documentation section

Here we tell ix to store the file inside /etc/whatever after it's been parsed, under the same name as the original file. Notice that the information related to ix is directly after the definition. This matters.


Concrete example

Assume we have a configuration that looks like this:

[colors]
blue = blue
red = green

We might then have a bash script that executes something and we want those colors to be given as parameters. Something like this:

#!/usr/bin/env bash
# magic.sh


#: ix-config
#: to: $HOME/.config/executable/executablerc

# ...

executable --color #{{ colors.blue }} # and so on...
# ...

Now when we run ix, it'll see that the magic.sh file is something that needs parsing, it'll make sure to replace everything within the #{{ }} characters with the value defined in the configuration, giving us the following file:

#!/usr/bin/env bash
# magic.sh

# ...

executable --color blue # and so on...
#...

Notice that it got rid of the ix definitions as well.


You might also like...
A minimal configuration for a dockerized kafka project.

Docker Kafka Quickstart A minimal configuration for a dockerized kafka project. Usage: Run this command to build kafka and zookeeper containers, and c

 Shai-Hulud - A qtile configuration for the (spice) masses
Shai-Hulud - A qtile configuration for the (spice) masses

Shai-Hulud - A qtile configuration for the (spice) masses Installation Notes These dotfiles are set up to use GNU stow for installation. To install, f

Lightweight library for accessing data and configuration

accsr This lightweight library contains utilities for managing, loading, uploading, opening and generally wrangling data and configurations. It was ba

An AddOn storing wireguard configuration

Wireguard Database Connector Overview Development Status: 0.1.7 (alpha) First of all, I'd like to thank Jared McKnight for wireguard who inspired me t

A Python3 script to decode an encoded VBScript file, often seen with a .vbe file extension

vbe-decoder.py Decode one or multiple encoded VBScript files, often seen with a .vbe file extension. Usage usage: vbe-decoder.py [-h] [-o output] file

This app converts an pdf file into the audio file.

PDF-to-Audio This app takes an pdf as an input and convert it into audio, and the library text-to-speech starts speaking the preffered page given in t

Fetch data from an excel file and create HTML file

excel-to-html Problem Statement! - Fetch data from excel file and create html file Excel.xlsx file contain the information.in multiple rows that is ne

JD-backup is an advanced Python script, that will extract all links from a jDownloader 2 file list and export them to a text file.

JD-backup is an advanced Python script, that will extract all links from a jDownloader 2 file list and export them to a text file.

An example file showing a simple endpoints like a login/logout function and maybe some others.

Flask API Example An example project showing a simple endpoints like a login/logout function and maybe some others. How to use: Open up your IDE (or u

Releases(v1.0)
Owner
Poly
​ ​​/​​​/ ​/ ​ / |​ ​ /​​​/​​​/ ​ |
Poly
Let's pretend you want to create a AWS Lambda project called "sns-processor".

Usage Let's pretend you want to create a AWS Lambda project called "sns-processor". Rather than using lambda and then editing the results to include y

null 1 Dec 31, 2021
Meera 2 May 12, 2022
validation for pre-commit.ci configuration

pre-commit-ci-config validation for pre-commit.ci configuration installation pip install pre-commit-ci-config api pre_commit_ci_config.SCHEMA a cfgv s

pre-commit.ci 17 Jul 11, 2022
Generate Openbox Menus from a easy to write configuration file.

openbox-menu-generator Generate Openbox Menus from a easy to write configuration file. Example Configuration: ('#' indicate comments but not implement

null 3 Jul 14, 2022
An implementation of multimap with per-item expiration backed up by Redis.

MultiMapWithTTL An implementation of multimap with per-item expiration backed up by Redis. Documentation: https://loggi.github.io/python-multimapwitht

Loggi 2 Jan 17, 2022
Esercizi di Python svolti per il biennio di Tecnologie Informatiche.

Esercizi di Python Un piccolo aiuto per Sofia che nel 2° quadrimestre inizierà Python :) Questo repository (termine tecnico di Git) puoi trovare tutti

Leonardo Essam Dei Rossi 2 Nov 7, 2022
A simple and easy to use Python's PIP configuration manager, similar to the Arch Linux's Java manager.

PIPCONF - The PIP configuration manager If you need to manage multiple configurations containing indexes and trusted hosts for PIP, this project was m

João Paulo Carvalho 11 Nov 30, 2022
MiniJVM is simple java virtual machine written by python language, it can load class file from file system and run it.

MiniJVM MiniJVM是一款使用python编写的简易JVM,能够从本地加载class文件并且执行绝大多数指令。 支持的功能 1.从本地磁盘加载class并解析 2.支持绝大多数指令集的执行 3.支持虚拟机内存分区以及对象的创建 4.支持方法的调用和参数传递 5.支持静态代码块的初始化 不支

keguoyu 60 Apr 1, 2022
Tenda D151 & D301 - Unauthenticated configuration download

Exploit Title: Tenda D151 & D301 - Unauthenticated configuration download (login included)

Ayoub 3 Jul 14, 2022
This is a method to build your own qgis configuration packages using osgeo4W.

This is a method to build your own qgis configuration packages using osgeo4W. Then you can automate deployment in your organization with a controled and trusted environnement.

Régis Haubourg 26 Dec 5, 2022