mnussbaum.base16-builder-ansible

base16-builder-ansible

This is a tool for creating and managing Base16 themes. Base16 helps generate color themes for various applications like Vim, Bash, or i3, using color schemes such as Tomorrow Night or Gruvbox.

The aim of this tool is to simplify the installation and updating of Base16 colors across many applications. Using Ansible to build Base16 themes allows us to create themes and save them as individual files or include them within larger configuration files. This is especially helpful for applications that only support one configuration file, like i3.

Instead of downloading pre-made color templates, this tool creates them in real-time. This lets us use newer Base16 color schemes that might not be available in older template repositories, ensuring we always have the latest colors.

Currently, it supports version 0.9.1 of the Base16 specification.

Example Usage

Here's how to use it in an Ansible playbook:

---
roles:
  - mnussbaum.base16-builder-ansible

tasks:
  # Create a specific color scheme and template, saving it to a variable
  - base16_builder:
      scheme: tomorrow-night
      template: shell
    register: base16_schemes

  # Use debug to show the registered result and learn how to access specific items.
  - debug:
      var: base16_schemes

  # Save the generated color scheme to a file
  - copy:
      content: "{{ base16_schemes['schemes']['tomorrow-night']['shell']['scripts']['base16-tomorrow-night.sh'] }}"
      dest: /my/bash/profile/dir/tomorrow-night-shell.sh

  # Build all templates for a specific color scheme
  - base16_builder:
      scheme: tomorrow-night
    register: base16_schemes

  # Build all color schemes for a specific template
  - base16_builder:
      template: shell
    register: base16_schemes

  # Build all color schemes for all templates
  - base16_builder: {}
    register: base16_schemes

  # Build color schemes for a few selected templates
  - base16_builder:
      template:
        - shell
        - i3
        - qutebrowser
    register: base16_schemes

  # Update to the latest color scheme and template source files without building
  - base16_builder:
      update: yes
      build: no

  # Download updates for and rebuild a specific template and color scheme
  - base16_builder:
      update: yes
      scheme: tomorrow-night
      template: shell
    register: base16_schemes

  # If you create your own Base16 color scheme, you can refer to it here
  - base16_builder:
      scheme: my-brand-new-color-scheme
      template: shell
      schemes_source: http://github.com/my-user/my-schemes-source-fork
      templates_source: http://github.com/my-user/my-templates-source-fork

Options

  • scheme: Specify a color scheme to build just that one instead of all. Not required; defaults to building all.
  • scheme_family: Specify a group of schemes to build. Not required; defaults to building all.
  • template: Specify which template or list of templates to build. Not required; defaults to building all.
  • cache_dir: Directory for storing cloned schemes, templates, and source data. Defaults to looking for specific environment variables or directories.
  • schemes_source: URL or path for locating color schemes. Defaults to a GitHub repository.
  • templates_source: URL or path for locating templates. Defaults to a GitHub repository.
  • update: Whether to clone or pull sources. Defaults to no.
  • build: Set to "no" to stop building any color schemes or templates. Defaults to yes.

Dependencies

  • Python 3.5 or higher (Python 2.7 may work but isn't tested)
  • Ansible
  • Pystache (install with pip install pystache)

Installation

Install this tool using ansible-galaxy:

$ ansible-galaxy install mnussbaum.base16-builder-ansible

After installation, reference it in your playbook and use the base16_builder module.

If you prefer, you can clone the repository and place it directly in your Ansible roles path.

Don't forget to also install the Pystache dependency as mentioned above.

Developing

To run tests, this project uses Pipenv. Run the following commands:

pip install --user pipenv
pipenv install --dev
pipenv run nose2

Or run tests in a Docker container for all supported Python versions:

./ci

License

MIT

To Do

  • Speed up git pulls.
  • Allow using unclaimed Base16 schemes.
Informazioni sul progetto

Builds and updates Base16 color schemes and templates so that you can install them into config files and render them into own dotfile templates

Installa
ansible-galaxy install mnussbaum.base16-builder-ansible
Licenza
mit
Download
184
Proprietario