filetailor is a peer-based configuration management utility for plain-text files such as dotfiles.

Overview

filetailor

filetailor is a peer-based configuration management utility for plain-text files (and directories) such as dotfiles. Files are backed up to a specified folder using filetailor, transferred to another device using tools such as Nextcloud, Syncthing, or Git, and then restored on other devices using filetailor again.

During the backup and restore process, filetailor can modify the file contents and path for the specific device according to variables and line-specific controls defined in YAML. See list of features.

flowchart

Table of Contents generated with DocToc

Example Usage

Here's how to sync a file to use dev1home on device1 and dev2home on device2.

.bashrc on device1:

alias MYHOME='/home/dev1home/' #{filetailor device1}
# alias MYHOME='/home/dev2home/' #{filetailor device2}
[[email protected] ~]$ filetailor add .bashrc
[[email protected] ~]$ filetailor backup

Sync the files using your preferred method of choice to device2 then restore. Lines with tags for other devices get automatically commented out.

[[email protected] ~]$ filetailor restore

.bashrc on device2:

# alias MYHOME='/home/dev1home/' #{filetailor device1}
alias MYHOME='/home/dev2home/' #{filetailor device2}

Getting Started

Installation

filetailor requires Python 3.6+ and pip. Install by running pip install filetailor. Setup by running filetailor init and following the instructions.

First install with pip and then generate the config file, filetailor.ini, to define where the synced files and YAML are to be saved.

$ pip install filetailor

$ filetailor init
Create "/home/username/.config/filetailor/filetailor.ini"? [Y/n] y

Created "/home/username/.config/filetailor/filetailor.ini".
Update "filetailor.ini" with your desired locations for synced files and configuration YAML, then run "filetailor init" again to create the directories.

$ filetailor init
Reading settings from "filetailor.ini"...
Creating filetailor directories...

Create "/home/username/.local/share/filetailor/sync" as sync_dir folder? [Y/n] y
Created "/home/username/.local/share/filetailor/sync".

Create "/home/username/.local/share/filetailor/yaml" as yaml_dir folder? [Y/n] y
Created "/home/username/.local/share/filetailor/yaml" and default "filetailor.yaml".

Create "/home/username/.cache/filetailor" as staging_dir folder? [Y/n] y
Created "/home/username/.cache/filetailor".

filetailor initialization complete.

See Alternative Installs for other installation methods.

Configuration

filetailor.yaml controls which files sync to which devices.

You can add/remove files to the YAML by running filetailor add PATHS and filetailor remove PATHS. Alternatively, you can update filetailor.yaml manually by following the comments within filetailor.yaml.

The YAML also defines variables, which are strings to replace when restoring to a specific device. An example of a variable would be a path to a file that differs between devices. See the FAQ in the wiki for examples.

Usage

To backup files from the local device to the sync folder, run filetailor backup.

To restore files from the sync folder to the local device, run filetailor restore.

To list all available arguments, run filetailor --help or for command details filetailor COMMAND --help.

Line-Specific Control

You can control the contents of individual files by device with line-specific controls such as the Example Usage above. There are two types of line-specific controls: single-line and multi-line.

To use a single-line control, append a tag to the line you want to be commented out on other devices. The line will be commented out on all devices except those listed within the tag. Single-line control tag format:

(Code being controlled) COMMENT_SYM{filetailor DEVICES...}

COMMENT_SYM is any symbol(s) used for comments and must be preceded by at least one space.

To control a block of lines, see Multi-line Controls.

Example: single-line control

How the code should be written on desktop1:

export $device_type="desktop" #{filetailor desktop}
# export $device_type="laptop" #{filetailor laptop1 laptop2}

After backing up the file through filetailor and then restoring to laptop1 or laptop2, the code would appear like this:

# export $device_type="desktop" #{filetailor desktop}
export $device_type="laptop" #{filetailor laptop1 laptop2}

How the code would look on any other device and in the filetailor sync folder:

# export $device_type="desktop" #{filetailor desktop}
# export $device_type="laptop" #{filetailor laptop1 laptop2}

Diff Tool

Before backing up or restoring files, filetailor will show a diff of the changes. To set the diff tool for filetailor, add the following option to filetailor.ini.

[TOOLS]
diff_tool = YOUR_FAVORITE_DIFF_TOOL

If diff_tool is not set, filetailor uses the first defined diff tool in the following list:

One popular diff tool is Delta. To install, follow the installation instructions in the link.

Run the following command to set Delta as your default pager for Git (and thus filetailor):

$ git config --global core.pager delta

More Help

See FAQ in the wiki for more help and examples.

Links:

Contributing

Feedback is welcome! Ways to contribute include:

  • Report a bug
  • Recommendations on new features
  • Suggestions to improve documentation and print statement readability

Pull requests are welcome as well, but please open an issue first describing the change. When submitting PRs, please try to conform to the following style guides:

You might also like...
Sync any your configuration file to remote. Currently only support gist.
Sync any your configuration file to remote. Currently only support gist.

Sync your configuration to remote, such as vimrc. You can use EscSync to manage your configure of editor, shell, etc.

Tools to assist with the configuration and maintenance of fapolicyd.

Tools to assist with the configuration and maintenance of fapolicyd.

Secsie is a configuration language made for speed, beauty, and ease of use.

secsie-conf pip3 install secsie-conf Secsie is a configuration language parser for Python, made for speed and beauty. Instead of writing config files

A slightly opinionated template for iPython configuration for interactive development
A slightly opinionated template for iPython configuration for interactive development

A slightly opinionated template for iPython configuration for interactive development. Auto-reload and no imports for packages and modules in the project.

Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files.
Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files.

Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards in settings file paths and mark setti

Generate config files and qr codes for wireguard vpn

wireguard config generator for python Generate config files and qr codes for wireguard vpn You will need to install qrcode and pillow in python and yo

Config files for my GitHub profile.

Config files for my GitHub profile.

Config files for my GitHub profile.

Hacked This is a python base script from which you can hack or clone any person's facebook friendlist or followers accounts which have simple password

Apt2sbom python package generates SPDX or YAML files

Welcome to apt2sbom This package contains a library and a CLI tool to convert a Ubuntu software package inventory to a software bill of materials. You

Comments
  • Document direction of changes

    Document direction of changes

    I believe the following facts should be made explicit in the documentation. Maybe you have fallen in the typical developer trap and they seem obvious to you, but they aren't and I would have avoided much frustration had I known. This happens to me all the time on programs I myself write, of course. So:

    1. filetailor backup only comments out the blocks conditional to the current device, and doesn't uncomment anything,
    2. filetailor restore only uncomments the blocks conditional to the current device, and doesn't comment out anything.

    I hope I got it right.

    Thanks for a great idea, btw! A passage between the Scylla of undisciplined proliferating versions of dotfiles and the Charybdis of keeping them in git -- one branch per host -- was badly needed.

    opened by nobrowser 2
Releases(v0.2.0)
  • v0.2.0(Aug 21, 2022)

    Breaking changes:

    • diff_tool was renamed to diff_pager to avoid confusion with the new difftool. You will need to update filetailor.ini by renaming diff_tool to diff_pager.

    Improvements:

    • Add new difftool option for manually selecting changes to copy with external tool such as Meld
    • Ask user before creating a new folder
    • Support variables in filetailor tag blocks within the file's contents, such as to expanding a variable to multiple device names
    • Improve readability of output formatting
    • Clean up code and docs

    Bug fixes:

    • Stop use of sudo when backing up files
    • Fix bug causing scripts to run when the file was not meant for the current device
    Source code(tar.gz)
    Source code(zip)
Inject your config variables into methods, so they are as close to usage as possible

Inject your config variables into methods, so they are as close to usage as possible

GDWR 7 Dec 14, 2022
MOHAconfig - Gerador de arquivo de configuração para Medal of Honor: Airborne

MOHAconfig Gerador de arquivo de configuração para Medal of Honor: Airborne MOHA - Gerador de arquivo de configuração. Essa aplicação foi feita em pyt

1 Dec 31, 2021
Napalm-vs-openconfig - Comparison of NAPALM and OpenConfig YANG with NETCONF transport

NAPALM vs NETCONF/OPENCONFIG Abstracts Multi vendor network management and autom

Anton Karneliuk 1 Jan 17, 2022
Python Marlin Configurator to make valid configuration files to be used to compile Marlin with.

marlin-configurator Concept originally imagined by The-EG using PowerShell Build Script for Marlin Configurations The purpose of this project is to pa

DevPeeps 2 Oct 09, 2021
Pydantic-ish YAML configuration management.

Pydantic-ish YAML configuration management.

Dribia Data Research 18 Oct 27, 2022
Config files for my GitHub profile.

Hacked This is a python base script from which you can hack or clone any person's facebook friendlist or followers accounts which have simple password

2 Dec 10, 2021
This Ivy plugin adds support for TOML file headers.

This Ivy plugin adds support for TOML file headers as an alternative to YAML.

Darren Mulholland 1 Nov 09, 2021
sqlconfig: manage your config files with sqlite

sqlconfig: manage your config files with sqlite The problem Your app probably has a lot of configuration in git. Storing it as files in a git repo has

Pete Hunt 4 Feb 21, 2022
Yamale (ya·ma·lē) - A schema and validator for YAML.

Yamale (ya·ma·lē) ⚠️ Ensure that your schema definitions come from internal or trusted sources. Yamale does not protect against intentionally maliciou

23andMe 534 Dec 21, 2022
Sync any your configuration file to remote. Currently only support gist.

Sync your configuration to remote, such as vimrc. You can use EscSync to manage your configure of editor, shell, etc.

Me1onRind 0 Nov 21, 2022
A compact library for Python 3.10x that allows users to configure their SimPads real-time

SimpadLib v1.0.6 What is this? This is a python library programmed by Ashe Muller that allows users to interface directly with their SimPad devices, a

Ashe Muller 2 Jan 08, 2022
Chinese-specific configuration to improve your favorite DNS server

Dnsmasq-china-list - Chinese-specific configuration to improve your favorite DNS server. Best partner for chnroutes.

Felix Yan 4.6k Jan 03, 2023
Apt2sbom python package generates SPDX or YAML files

Welcome to apt2sbom This package contains a library and a CLI tool to convert a Ubuntu software package inventory to a software bill of materials. You

Eliot Lear 15 Nov 13, 2022
A lightweight Traits like module

Traitlets home https://github.com/ipython/traitlets pypi-repo https://pypi.org/project/traitlets/ docs https://traitlets.readthedocs.io/ license Modif

IPython 532 Dec 27, 2022
Strict separation of config from code.

Python Decouple: Strict separation of settings from code Decouple helps you to organize your settings so that you can change parameters without having

Henrique Bastos 2.3k Dec 30, 2022
Pyleri is an easy-to-use parser created for SiriDB

Python Left-Right Parser Pyleri is an easy-to-use parser created for SiriDB. We first used lrparsing and wrote jsleri for auto-completion and suggesti

Cesbit 106 Dec 06, 2022
ConfZ is a configuration management library for Python based on pydantic.

ConfZ – Pydantic Config Management ConfZ is a configuration management library for Python based on pydantic. It easily allows you to load your configu

Zühlke 164 Dec 27, 2022
Generate config files and qr codes for wireguard vpn

wireguard config generator for python Generate config files and qr codes for wireguard vpn You will need to install qrcode and pillow in python and yo

18 Dec 02, 2022
An application pulls configuration information from JSON files generated

AP Provisioning Automation An application pulls configuration information from JSON files generated by Ekahau and then uses Netmiko to configure the l

Cisco GVE DevNet Team 1 Dec 17, 2021
Scooch Configures Object Oriented Class Hierarchies for python

Scooch Scooch Configures Object Oriented Class Hierarchies for python. A good place to start with Scooch is at the documentation found here. Scooch is

Pandora Media, Inc. 6 Dec 20, 2022