Giter Site home page Giter Site logo

dotlink's Introduction

dotlink

There are countless ways of managing your dotfiles.. this is one of them. After trying several approaches and switching between different setups, this method finally met all of my requirements:

  • As simple as possible
  • Multiple hosts are managed in one repository
  • Identical configurations for one program on several hosts only need to be adjusted in one place
  • Different configurations for one program on several hosts are no problem
  • Set everything up with one command
  • Updating configurations shall require nothing more than git pull

This is a reference repository which contains a bash script (dotlink) and some example dotfiles for two hosts (host1 and host2).

Warning: If you want to try this make a backup of your dotfiles! The script doesn’t overwrite existing files but you never know.

Concept

The concept is based on symlinks and two directories, common and hosts.

The hosts directory contains subdirectories for all hosts on which dotfiles are managed. They need to match the hostname of the host (in this repository host1 and host2) and mimic the corresponding $HOME directories.

The common directory contains configs which are present on multiple hosts. It doesn’t follow any specific structure, you can choose what suits your setup. Subdirectories with program names, followed by the configuration files (in this repository only mpv) make probably the most sense but its up to you. The common directory should never contain symlinks.

Symlinks from the hosts directory to the common directory make the configs available on multiple hosts and they can be adjusted in one place (see mpv in this repository).

Here is the tree output from this repository:

dotlink/
├── common
│   └── mpv
│       ├── input.conf
│       └── mpv.conf
├── hosts
│   ├── host1
│   │   ├── .config
│   │   │   └── mpv -> ../../../common/mpv/
│   │   └── .offlineimaprc
│   └── host2
│       └── .config
│           ├── beets
│           │   └── config.yaml
│           └── mpv -> ../../../common/mpv/
└── dotlink

The mpv configuration is shared between hosts, host1 has an OfflineIMAP configuration in his home directory and host2 has a beets configuration in his .config directory.

Every file from every hosts/<hostname> directory can then be linked to the corresponding path into the home directory of the host. This can be done by hand or with help of the dotlink script.

If you updated a configuration somewhere else just call git pull and thats it.

Script usage

When the dotlink script is executed, all files from the hosts/<hostname> directory, which matches the current hostname, are linked to their destination in the $HOME directory. Executing the script is only neccessary when new files were added which are not linked yet.

The script can be executed from everywhere, it is just important that it’s stored next to a hosts directory like in this repository.

Usage: dotlink [OPTIONS]

Link all files from hosts/$HOSTNAME to $HOME.

OPTIONS
  -h, --help    Show this help message and exit
  -u, --unlink  Remove current links

Add configuration files for only one host

Add the files to hosts/<hostname>/<path_in_home> and execute the dotlink script on the modified host. If you want to keep all configuration files in the common directory and just use symlinks in the hosts directory, you can follow the instructions below.

Add configuration files for multiple hosts

It is important that the links from the hosts directory to the common directory are relative. Follow these steps to add new configurations for multiple hosts:

  1. Add the files somewhere to the common directory
  2. Execute ln -rs common/<config_or_directory> hosts/<hostname>/<path_in_home> for every host on which the files should be present
  3. Execute the dotlink script on every modified host

dotlink's People

Contributors

deleh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.