What are DOT-files?

Unix: What's the easiest way to manage dotfiles on Github by using symlinks?

  • Tell it to me like I am a child please. Do you symlink from the repo TO your home directory or vice-versa?

  • Answer:

    I don't know, if it is the best or easiest way, but I got my inspiration for https://github.com/rathier/rat_dotfiles on http://blog.smalleycreative.com/tutorials/using-git-and-github-to-manage-your-dotfiles/ Basicaly you keep your dotfiles (without the dot) in a subdir and link to them. Use a script like the one on the smalleycreative-blog. That will also make backups in another directory. Then you could edit your files an update them to github (or other online git repositories). Like it is explained by Michael Smalley on his blog. You want to read that blog-entry, the explanation there is quite good. It covers basic git knowlegde, it covers how to create a repository on github and how to link and backup your dotfiles.

Rainer Thierfelder at Quora Visit the source

Was this solution helpful to you?

Other answers

I don't have an excellent blog post like the one has mentioned. It's honestly well written and worth a read. However, I have developed my own method to manage my dotfiles and sync them across machines using Git. The higher level overview of the way I handle dotfiles is essentially the same as mentioned in Rainer's answer: You store all the files you want to track and sync in a single git repository and then symlink them to their correct places across the filesystem. While the basic design is the same, I've created a slightly more complex and sophisticated solution. Though it still needs a lot of refinement. Things that happen if more people show an interest in it. Take a look at my dotfiles repo on GitHub: https://github.com/darnir/dotfiles A major issue when backing up and syncing dotfiles via GitHub is configuration files that contain sensitive information like passwords or SSH Private Keys. I devised a small mechanism for that and will explain how this script works to handle said use case too. Just like any other package manager, this system is based on the concept of packages. This allows me to selectively install my dotfiles on a new machine. I've found this to be very useful when I'm on some remote machine and need only my vim configuration around and nothing else. Each package is supposed to contain all the configuration files for that particular application. For example, the Bash package in my dotfiles contains the following files: bashrc bash_aliases bash_functions bash_colours bash_profile inputrc All of these files will be installed together on the target system when the Bash dotfiles package is installed. First, let me explain the usage. I'm going to assume a rudimentary knowledge of git and bash here. If you can start a console window and clone a repository, you're good to go! Usage Usage: ./dotfiles [Options] List of valid options: -I package : Install dotfiles package "package" -l : List available packages -h : Print this help and exit Remember, this script must only be invoked from the root dir of the repository Very simple, isn't it? First, a caveat: Since I was too lazy to do it correctly, the dotfiles script can only be called from the root directory of the repository. So, if you cloned the repository to ~/dotfiles/, you **must** be in the ~/dotfiles/ directory to execute it. A package is a directory in which contains all the files that have to be installed to the local filesystem. For example, the command line: $ ./dotfiles -I Bash will install all the above mentioned configuration files to their respective location on the filesystem. When I say "install", the files are actually symlinked to their location on the filesystem so that any changes to the files are immediately reflected back in the repository. Now, how does the script know where each file should be symlinked? For this, we need to write a small InstallScript. It's not difficult and is a one time effort only. InstallScriptsThe InstallScript is a valid Bash file that tells the ./dotfies script where and how each file should be symlinked. It allows for a lot of customization should you want it. An install script is a valid bash script which is executed to install a particular package. An install script must define the PACKAGE_NAME variable  at the very beginning. This variable is used to locate the configuration file in the repository. Any file being marked for install is expected in $PACKAGE_NAME/ directory in the repository. The dotfiles manager calls the following functions in the same order, if they are defined: prepare(): Used to perform initialization tasks before a package is   installed. This is includes creating the directory structure, setting   environment variables, etc. install(): This function is always called by the script and must  always be defined. It is used for the actual installation of the files   in the system. post_install(): Used to perform some post-installation tasks like   setting the attributes of some file, or installing files not included in   dotfiles. Here, we use the word, "install" to imply the act of creating a symlink from the file in the repository to the path on the system where the configuration file is expected to exist. For example, to the bashrc file is generally expected to exist in ~/.bashrc, hence installing the file is equivalent to running the command $ ln -s $PWD/Bash/bashrc $HOME/.bashrc from the root of the repository. To make things easier, the package manager provides some helper functions that can be utilized for installing files and directories: install_file(): Expects 4 parameters File Name: This is the exact name of the file as it exists in the  package Final Location: The location where this file should be symlinked.  It accepts full paths, up to the final directory but not the filename,  or you can use one of the given shortcut paths: home: Store in $HOME after adding a dot (.) prefix to the filename. This is the most common location you'll use. etc: Store in /etc systemd-user: Store in $HOME/.config/systemd/user/ as a systemd user session unit bin: Store in /usr/local/bin autostart: A X autostart file, store in $HOME/.config/autostart Sudo: Boolean value. Does the file need to be linked with root  privileges? Link Type: What kind of a link should be made? This should always  be true, which implies soft links. Only certain files, such as systemd units should be hard linked. install_private_file(): This function is similar to install_file()[/code[ except that it expects the file being symlinked to exist in [code sh]/media/truecrypt1/ instead of in the dotfiles package. This function  is used to install files which contain sensitive information and hence are  stored in a secure container instead of committing them to a public repository. install_directory(): This function is used to install a complete  directory as a symlink. Useful when there are a lot of configuration files within a single directory. Most common use case is ViM. As you can see, the InstallScript API provides for a lot of customization in how the file is installed on the target system. My dotfiles repo has examples on how each of the above options / variations are used. If there's something extra or more fancy required, you can change the dotfiles_internal.sh file to support it. I'd be happy to accept a pull request too :) Currently, this system of managing dotfiles is integrated along with my own dotfiles. However, if people are interested, I would be willing to split them up and upload the architecture for you to use separately. Just let me know via comments here or on GitHub. I'm willing to put in the effort only if someone is interested.

Darshit Shah

I use gists. The downside is I need to keep the syncable file in a different location to the actual file being used (because I don't want to create a Git project in my home directory) but apart from that it's pretty simple. I can then simply fetch && pull or push that gist. I could write a script that does the copying & syncing automatically if I can't be bothered to do the steps manually.

Marko Poutiainen

I have a single dotfiles git repo that i checkout into ~/dotfiles. I then symlink from ~/.whatever to dotfiles/whatever I have a separate repo just for my .vim folder

Clint Liddick

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.