Skip to main content

Save your dotfiles once, deploy them everywhere

Project description

dotdrop



Tests Status Doc Status License: GPL v3 Coverage Status Language grade: Python

PyPI version AUR Python

Donate

Save your dotfiles once, deploy them everywhere

Dotdrop makes the management of dotfiles between different hosts easy. It allows you to store your dotfiles in Git and automagically deploy different versions of the same file on different setups.

It also allows you to manage different sets of dotfiles. For example, you can have a set of dotfiles for your home laptop and a different set for your office desktop. Those sets may overlap, and different versions of the same dotfiles can be deployed using different predefined profiles. Or you may have a main set of dotfiles for your everyday host and a subset you only need to deploy to temporary hosts (cloud VM etc.) that may be using a slightly different version of some of the dotfiles.

Features:

  • Sync once every dotfile in Git for different usages
  • Allow dotfile templating by leveraging Jinja2
  • Dynamically generated dotfile contents with pre-defined variables
  • Comparison between deployed and stored dotfiles
  • Handling multiple profiles with different sets of dotfiles
  • Easily import and update dotfiles
  • Handle files and directories
  • Support symlinking of dotfiles
  • Associate actions to the deployment of specific dotfiles
  • Associate transformations for storing encrypted/compressed dotfiles
  • Provide solutions for handling dotfiles containing sensitive information

Also check out the blog post, the example, the documentation or how people are using dotdrop for more.

Quick start:

mkdir dotfiles && cd dotfiles
git init
git submodule add https://github.com/deadc0de6/dotdrop.git
pip3 install -r dotdrop/requirements.txt --user
./dotdrop/bootstrap.sh
./dotdrop.sh --help

A mirror of this repository is available on GitLab under https://gitlab.com/deadc0de6/dotdrop.

Why dotdrop?

There exist many tools to manage dotfiles; however, not many allow you to deploy different versions of the same dotfile on different hosts. Moreover, dotdrop allows you to specify the set of dotfiles that need to be deployed for a specific profile.

See the example for a concrete example of why dotdrop rocks.


Table of Contents

Installation

There are multiple ways to install and use dotdrop. It is recommended to install dotdrop as a submodule to your dotfiles Git tree. Having dotdrop as a submodule guarantees that anywhere you are cloning your dotfiles Git tree from you'll have dotdrop shipped with it.

The below instructions show how to install dotdrop as a submodule. For alternative installation instructions, see the installation documentation.

Dotdrop is also available on:

As a submodule

The following will create a git repository for your dotfiles and keep dotdrop as a submodule:

## create the repository
$ mkdir dotfiles; cd dotfiles
$ git init

## install dotdrop as a submodule
$ git submodule add https://github.com/deadc0de6/dotdrop.git
$ pip3 install -r dotdrop/requirements.txt --user
$ ./dotdrop/bootstrap.sh

## use dotdrop
$ ./dotdrop.sh --help

For macOS users, make sure to install realpath through Homebrew (part of coreutils).

Using dotdrop as a submodule will require you to work with dotdrop by using the generated script dotdrop.sh at the root of your dotfiles repository. Note that this script updates the submodule automatically unless called with the environment variable DOTDROP_AUTOUPDATE set to no.

To ease the use of dotdrop, it is recommended to add an alias to it in your shell (~/.bashrc, ~/.zshrc, etc.) with the config file path, for example:

alias dotdrop='<absolute-path-to-dotdrop.sh> --cfg=<path-to-your-config.yaml>'

Completion scripts exist for bash, zsh and fish; see the related doc.

Getting started

Create a new repository to store your dotfiles with dotdrop. Init or clone that new repository and install dotdrop.

Then import any dotfiles (files or directories) you want to manage with dotdrop. You can either use the default profile (which resolves to the hostname of the host you are running dotdrop on) or provide it explicitly using the switch -p/--profile.

Import dotfiles on host home:

$ dotdrop import ~/.vimrc ~/.xinitrc ~/.config/polybar

Dotdrop does two things:

  • Copy the dotfiles to the dotpath directory (defined in config.yaml, defaults to dotfiles)
  • Create the associated entries in the config.yaml file (in the dotfiles and profiles entries)

Your config file will look like something similar to this:

config:
  backup: true
  banner: true
  create: true
  dotpath: dotfiles
  ignoreempty: false
  keepdot: false
  longkey: false
  showdiff: false
  workdir: ~/.config/dotdrop
dotfiles:
  d_polybar:
    dst: ~/.config/polybar
    src: config/polybar
  f_vimrc:
    dst: ~/.vimrc
    src: vimrc
  f_xinitrc:
    dst: ~/.xinitrc
    src: xinitrc
profiles:
  home:
    dotfiles:
    - f_vimrc
    - f_xinitrc
    - d_polybar

For a description of the different fields and their use, see the config doc.

Commit and push your changes with git.

Then go to another host where your dotfiles need to be managed as well, clone the previously set up repository, and compare the local dotfiles with the ones stored in dotdrop:

$ dotdrop compare --profile=home

Now you might want to adapt the config.yaml file to your liking on that second host. Let's say, for example, that you only want d_polybar and f_xinitrc to be deployed on that second host. You would then change your config to something like this (assuming that the second host's hostname is office):


profiles:
  home:
    dotfiles:
    - f_vimrc
    - f_xinitrc
    - d_polybar
  office:
    dotfiles:
    - f_xinitrc
    - d_polybar

Then adapt any dotfile using the templating feature (if needed). For example, you might want different fonts sizes in Polybar for each host.

Edit <dotpath>/config/polybar/config:

{%@@ if profile == "home" @@%}
font0 = sans:size=10;0
{%@@ elif profile == "office" @@%}
font0 = sans:size=14;0
{%@@ endif @@%}
font1 = "Material Design Icons:style=Regular:size=14;0"
font2 = "unifont:size=6;0"

You also want to have the correct interface set on the wireless network in the Polybar config.

Add a variable to the config file (In the below example, home gets the default wlan0 value for the variable wifi while office gets wlp2s0):


variables:
  wifi: "wlan0"

profiles:
  home:
    dotfiles:
    - f_vimrc
    - f_xinitrc
    - d_polybar
  office:
    dotfiles:
    - f_xinitrc
    - d_polybar
    variables:
      wifi: "wlp2s0"

Then you can adapt the Polybar config file so that the variable wifi gets correctly replaced during installation:

[module/wireless-network]
type = internal/network
interface = {{@@ wifi @@}}

Also, the home computer is running awesomeWM, and the office computer bspwm. The ~/.xinitrc file will therefore be different while still sharing some lines.

Edit <dotpath>/xinitrc:

#!/bin/bash

# load Xresources
userresources=$HOME/.Xresources
if [ -f "$userresources" ]; then
      xrdb -merge "$userresources" &
fi

# launch the wm
{%@@ if profile == "home" @@%}
exec awesome
{%@@ elif profile == "office" @@%}
exec bspwm
{%@@ endif @@%}

Finally you want everything installed with the office profile to be logged; you thus add an action to the config file:


actions:
  loginstall: "echo {{@@ _dotfile_abs_src @@}} installed to {{@@ _dotfile_abs_dst @@}} >> {0}"

profiles:
  home:
    dotfiles:
    - f_vimrc
    - f_xinitrc
    - d_polybar
  office:
    dotfiles:
    - f_xinitrc
    - d_polybar
    variables:
      wifi: "wlp2s0"
    actions:
      - loginstall "/tmp/dotdrop-installation.log"

When done, you can install your dotfiles using:

$ dotdrop install

If you are unsure, you can always run dotdrop compare to see how your local dotfiles would be updated by dotdrop before running install or you could run install with --dry.

That's it, a single repository with all your dotfiles for your different hosts.

For more, see the docs:

Documentation

Dotdrop's documentation is hosted on Read the Docs.

Thank you

If you like dotdrop, buy me a coffee.

Contribution

If you are having trouble installing or using dotdrop, open an issue.

If you want to contribute, feel free to do a PR (please follow PEP8). Have a look at the contribution guidelines.

License

This project is licensed under the terms of the GPLv3 license.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dotdrop-1.8.0.tar.gz (70.1 kB view details)

Uploaded Source

Built Distribution

dotdrop-1.8.0-py3-none-any.whl (72.8 kB view details)

Uploaded Python 3

File details

Details for the file dotdrop-1.8.0.tar.gz.

File metadata

  • Download URL: dotdrop-1.8.0.tar.gz
  • Upload date:
  • Size: 70.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for dotdrop-1.8.0.tar.gz
Algorithm Hash digest
SHA256 33b8b2557a855e59f8f6f5ca5dd2d961c5aaa47074105b7bbc4222220f582f45
MD5 423af821f714c7bbf75fb35a16f8a3f9
BLAKE2b-256 1ba9b1e9da815a334211a15d04ac1fe82e442910686b5b294fcc85c3f81bb38a

See more details on using hashes here.

File details

Details for the file dotdrop-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: dotdrop-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 72.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for dotdrop-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4b19e4df9bb6b7f0abfbe70982550de5da9de5b5cd7ab541b982a259dca6226
MD5 0a1cce9e9eb5e85fd51611523d816595
BLAKE2b-256 1212b6e31701685a0ed0e610b8433daca7be35b1bf6c9db8eaadcce616d2cb64

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page