Skip to content

Instantly share code, notes, and snippets.

@wucke13
Last active April 5, 2018 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wucke13/7a5549fcec9992b8f7ccacc3c4436f0c to your computer and use it in GitHub Desktop.
Save wucke13/7a5549fcec9992b8f7ccacc3c4436f0c to your computer and use it in GitHub Desktop.

Whats this?

This is a simple, plain, bash solution to manage selected dotfiles. It's primary use case is two sync selected, but not necessarly all dotfiles between multiple computers. Using this script, you can seperate your dotfiles in the ones you would like to keep (in sync) and the ones you won't. It uses symlinks to let your programs access theire dotfiles from where they excpect them to be, without acutally having them there.

How to?

  • Create a folder anywhere. My suggestion is to do it in some sort of a "documents" folder.
    • Example: mkdir -p $HOME/documents/projects/dotfiles
  • Save the script below in the created folder.
  • Run the script once. It will generate folders named config, home, local_share in the folder created.
  • Now you have to decide, which dotfiles you want to manage.
    • Lets say you want to manage your .Xresources file. It resides in your $HOME folder, so you move it from there to the generated home folder in the dir you created. mv $HOME/.Xresources $HOME/documents/projects/dotfiles/home/
    • Now run the script once. It will crawl through the folders config, home, local_share looking for "things" (folders or files). Every-"thing" it finds will be symlinked to its destination (config to $HOME/.config/, home to $HOME/, local_share to $HOME/.local/share/).

When to re-run the script?

When you add or remove a first level element of one of the generated folders, so when ls config home local_share shows something diffrent then before.

When not to re-run the script?

  • When you add/remove files inside of the first level folder of one of the generated folders (e.g. touch home/autostart/test.desktop).
  • When you edit the content of a file (regardless whether it's first level like home/.Xresources or not.

Why?

I have a heavily customized window manager with lots of relevant dotfiles. However, I don't want to sync all my dotfiles, because there are tons of files I don't really need/want. This script enables me to store my "wanted" dotfiles somewhere in my documents folder, which is synced to all of my computers. Bonus 1: when you want to clean your dotfiles, simply delete them (but ensure not to follow symlinks for a recursive deletion). Then re-run the script. It will fill set up everything as whished. Bonus 2: new, fresh installation, all of your dotfiles missing? Get hold of your old folder containing your config and the script. Run the script. Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment