DEV Community

Manage Your Dotfiles Like a Superhero

Jake Wiesler on September 20, 2021

I'm going to assume you are reading this because: you have one or more dotfiles lying around and you don't know how to organize them. you heard t...
Collapse
 
mandarvaze profile image
Mandar Vaze

I use similar approach.
I do have dotfiles repo on GitHub that is severely outdated. Instead I have all my dotfiles in a folder called dotfiles in Dropbox.

I symlink them to my home folder.

Benefit : I don't have to remember to git commit/push. They are automatically saved by Dropbox.
🎉

Collapse
 
mxyzplkt profile image
Jeremiah Hundley

I do that too. They're small, so it's free. Yay. I do the same thing with my second brain - Logseq, Obsidian and Craft

Collapse
 
grizzlysmit profile image
Francis Grizzly Smit

I just use chezmoi github.com/twpayne/chezmoi , it uses git to store the dot files for me, it's great

Collapse
 
mxyzplkt profile image
Jeremiah Hundley

Oh this is great.... I have already put most of my dotfiles in a .dotfiles folder using the same structure, but by hand, invoking the symlink command:

ln -s .dotfiles/package/ ~/

I am in the middle of doing this right now, lol. My question is if I install stow, will it mess up my directory?

Second, if I use snow, and say, import my .dotfiles from my MacBook Pro 16 to my MacBook Pro 15 -> running Lenox, will my Lenox machine recognize them and can it use them?

Also, I tested everything to make universal commands on the Mac to make the symlink in my home directory invisible even when show hidden files are on.

I was also considering doing the same things to manage my paths and executables. Not for back up, only to have them all in one simple place. Like Crontab

Collapse
 
mandarvaze profile image
Mandar Vaze • Edited

About your second question, I'm not sure what Lenox mean. I'm assuming you mean linux.
If that is the case, I've been there.
The problem I faced is that some of my dotfiles had absolute path to the home directory which on macOS is like /Users/mandar - This results into path not found errors on linux where home directory is /home/mandar
One precaution you may take is to use $HOME rather than actual path.

Collapse
 
jakewies profile image
Jake Wiesler

Hey Jeremiah,

Stow is pretty sophisticated. It shouldn't mess up your directory.

To answer your second question, you should git clone your .dotfiles directory onto the other machine, install stow and then run stow for each subdirectory within .dotfiles to ensure your configs get placed into the right part of your machine.

Collapse
 
bdelespierre profile image
Benjamin Delespierre

I accumulated a lot of conf using this method 👍 Here are my dotfiles github.com/bdelespierre/dotfiles

Collapse
 
jakewies profile image
Jake Wiesler

Nice Benjamin!

Collapse
 
michaelcade1 profile image
Michael Cade

Great post but I would argue a git bare repo / folder is a better way to go vs symlinks?

Collapse
 
jakewies profile image
Jake Wiesler

Hey Michael thanks for the reply! I've used git bare repos in the past and always felt confused by them. They aren't as intuitive as using stow in my opinion. But different strokes!

Collapse
 
grimm26 profile image
Mark Keisler

What happens when you have two or more packages that use . config/ ? Will it still try to symlink that directory? It would be much better to make sure the directory is created and only symlink files.

Collapse
 
jakewies profile image
Jake Wiesler • Edited

Great question! I can only answer from experience. There may be a more sophisticated answer.

Before setting up my .dotfiles in the way I described in this post, I had a .config directory with a few subdirectories for packages I use routinely. I don't need to version control these packages, so they aren't stowed in my .dotfiles directory.

stow realizes this, and instead of symlinking the entire .config directory, it goes one level deeper and symlinks the stowed directory. This preserves the rest of the folders in .config from being symlinked.

So what this looks like using a stowed nvim directory:

.dotfiles
    nvim
       .config
            nvim
                .dotfile
.config 
    package-1
    package-2
    nvim -> .dotfiles/nvim/.config/nvim
Enter fullscreen mode Exit fullscreen mode

Hope this answers your question!