Giter VIP home page Giter VIP logo

dotfiles.sh's Introduction

Dotfiles made easy

So you've decided to version-control your dotfiles, and you're looking for a way to do it for you, and all of a sudden you hit this snag. It's a pretty simple snag, but no one really seems to have a nice solution for it: symlink farms linking all your files into $HOME is ugly, but so is turning $HOME itself into a git repository annd having all your git metadata there (for example, ensuring that git commands will always fall back to acting on your dotfiles). :( If only there was some way to have the best of both worlds...

Enter dotfiles, a simple wrapper around git that runs all git commands with a custom $GIT_DIR, allowing metadata to be stored separate from the files. gitignore and gitattributes files can be easily hidden through the use of sparse checkout. A handful of administrative commands are also provided to bootstrap the repository.

Usage

  • dotfiles init /path/to/metadata

Initialize a new bare git repository, configured to treat $HOME as the worktree. $GIT_DIR/info/sparse-checkout is seeded with .gitignore, .gitattributes, and README.md. $GIT_DIR/info/exclude is seeded with a gitignore file ignoring common types of uninteresting files. Configure git status to not list untracked files.

  • dotfiles clone protocol://domain.name/repo.git /path/to/metadata

Instead of init'ing a new repo, clone it from somewhere, and try to extract a usable gitignore/gitattributes and copy it to $GIT_DIR/info/. If it is possible to do so without overwriting, checkout all files too.

  • dotfiles ignore [PATTERN] ...

Append new patterns to $GIT_DIR/info/exclude, or directly edit it if no patterns are given. Then utilize the git plumbing to add the file contents to the index as .gitignore itself.

  • dotfiles attributes [ATTRIBUTES] ...

Append new gitattribute lines to $GIT_DIR/info/attributes and... well, you get the drill. :)

  • dotfiles readme

Edit your README.md in a temporary file so you can talk about what it does etc. Once again this is directly read into the index without actually manifesting in $HOME (because having some readme file in your home directory is cluttersome, but you still want it to show up on Github or wherever).

Encrypting secret files.

No especial effort has been taken to magically take care of files that should be synced, but not everyone should be able to read. I've found that I don't need to reinvent the wheel, as git-crypt works very well in that regard without extra effort. Simply add the following dotfiles attributes lines, then commit the secret files like any other:

[attr]crypt      filter=git-crypt diff=git-crypt

fileglob1        crypt
.bash_secrets    crypt
[...]

The git-crypt key will be stored in $GIT_DIR/git-crypt/ and can be exported and transferred separately.

Portability notes

/bin/sh with support for the local keyword is assumed. This is the default on systems where the default sh is: bash (macOS, most forms of Linux), busybox (embedded Linux), or ash/dash (Debian, BSD).

A readlink utility supporting GNU's -m option is assumed. If the GNU coreutils version is available via the name greadlink, for example on macOS via brew install coreutils, it will be preferred.

License

This project is licensed under the terms of the GNU General Public License, version 2, or (at your option) any later version.

dotfiles.sh's People

Contributors

alfunx avatar eli-schwartz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotfiles.sh's Issues

Side note: de-ugly (unfortunate wording)

Dear Sir,

the sentence: symlink farms linking all your files into $HOME is ugly
is not objective.

Using symlinks from a version controlled repository in ${HOME} is secure and simple. Consider switching between configurations. It is easy with symlinks. And it allows for gradual merging and rebasing of changes after having switched to an entirely new base system that comes with some initial config already that you want to add your changes to.

Your work is interesting and functional. No worries. No offense meant. It is just that ugly is not valid argument. It is subjective.

Kind regards,
another Linux advocate; thanks for your work and quality support (forum & co). aurhelper looks helpful too

Could you add an explanation to replicate the dotfiles on a new installation

Thank you you for your work it is really nice !

I am using it on my desktop and the installation went well however now I want to
replicate this installation on my laptop and when I try to
dofiles clone https://myrepo.com /path/to/metadata

I have the following error :
fatal : working tree /home/myname already exists

I think I could go around this error with some option like --separate-git-dir but I am not sure and from your README I can't understand how to use your wrapper for this case.
Thank you in advance for your help

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.