MyNixOS website logo
Description

A simple config file swapping tool.

Confetti

Build Status

Confetti is a tiny tool for managing different versions of a particular configuration file, and quickly swapping them.

Confetti is set up via a spec file, ~/.confetti.yml. You can specify one or more groups, each with one or more targets, which are the config files you wish to manage.

Suppose we have multiple AWS credential files we want to easily switch between (ie use various ~/.aws/credentials variants). To use confetti for this task, we'll put our different files in the target directory, ~/.aws, named ~/.aws/${variant-name}.credentials. We might have:

~/.aws/personal.credentials
~/.aws/work.credentials
~/.aws/org_name.credentials

A simple example group specification in ~/confetti.yml might look like:

groups:
  - name: aws
    targets:
      - /home/you/.aws/credentials

To switch to work.credentials simply run:

$ confetti [required group_name] [optional variant_name]

eg.

$ confetti aws work
> Setting aws to "work"
> ~/.aws/credentials -> ~/.aws/work.credentials
> Success (ノ◕ヮ◕)ノ*:・゚✧

As you can see from the example output, this will symlink ~/.aws/credentials -> ~/.aws/work.credentials. If the target file is not a symlink when you invoke confetti, a backup will be made before your variant file is linked. If you have multiple target files in your group, they will all be symlinked to their respective variants.

You can specify alternative search_paths for each group, and whether or not to search recursively. Adding a new group with this functionality could make our .confetti.yml look like:

groups:
  - name: aws
    targets:
      - ~/.aws/credentials
  - name: dotfiles
    targets:
      - ~/.spacemacs
      - ~/.vimrc
      - ~/.zshrc
      - ~/.zpreztorc
      - ~/.tmux.conf
      - ~/.tmux.style.conf
    search_paths:
      - path: ~/dotfiles
        recursive: true

This makes confetti a great tool for managing things like dotfiles, where the target config files are located in a github repo anywhere on the machine. Simply running: confetti dotfiles could link ~/.spacemacs -> the first .spacemacs found in a recursive search of ~/dotfiles. If your workflow involves regularly swapping any such files, the small amount of initial configuration can be well worth the cost!

One last feature is that you can specify a top level common section that will be applied to all other groups. For instance:

common:
  targets:
      - ~/dir/some.file
  search_paths:
    - path: ~/some/directory
      recursive: false

Now, every group we try to use confetti for will also link ~/dir/some.file, and will also use /some/directory as a search path.

Installing

MacOS

You can install with brew via:

$ brew tap aviaviavi/homebrew-tap
$ brew install aviaviavi/homebrew-tap/confetti

Linux

A linux binary can be found on the releases page.

Source

You can install from source with stack.

Windows

Confetti does not currently work on Windows, as there is some reliance on POSIX for dealing with the file system. In theory it should be fairly straight-forward to get it working on Windows if anyone is up for implementing it. Feel encouraged to submit a PR or reach out for any related discussion.

Contributing

Contributions in any form are welcome!

Future Features

  • Config groups should be able to source bash files or sets of environment variables.
Metadata

Version

1.0.0

License

Executables (1)

  • bin/confetti

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows