If you spend any meaningful time customizing your Bash or Zsh
environment then it's worth backing up your hard work. This page is a collection
of resources for managing your dotfiles (.bashrc
, .zshrc
, .vimrc
, etc.).
GNU Stow is a useful tool for managing your dotfiles. It allows you to organize all of your dotfiles into logical groupings or "packages", combine those packages into a version controlled directory, and then symlink each of the dotfiles to the correct locations on your system. There are historical reasons why this has been a problem. However, it also provides modern convenience and value when it comes to managing your personal dotfiles.
On gLinux you can install stow with apt.
$ sudo apt install stow
$ brew install stow
To take advantage of stow defaults, it is typical to store your dotfiles directory in your home directory (where the dotfiles will be symlinked to.) If you version control your dotfiles with Git, you can clone them directly into your home directory.
$ git clone sso://user/$USER/dotfiles $HOME/dotfiles && cd ~/dotfiles
If for example, your dotfiles tree looks like this:
~
└── dotfiles
├── vim
| └── .vim
| └── vimrc
└── zsh
└── .zshrc
Then you can invoke stow
from your dotfiles directory to link all of your
dotfiles to their appropriate tree locations in your home directory with one
invocation:
$ cd ~/dotfiles && stow vim zsh
Which will establish the following symlinks.
~/dotfiles/vim/.vim/vimrc
—>~/.vim/vimrc
~/dotfiles/zsh/.zshrc
—>~/.zshrc
Neat! You can also "unstow" files as well to unlink. See the docs.
Assuming you have the following directory structure:
experimental/users/{{USERNAME}}
└── dotfiles
├── vim
| └── .vim
| └── vimrc
└── zsh
└── .zshrc
Then run:
stow -t $HOME -d /$repo/dotfiles vim zsh
If you get a existing target is not owned by stow
error, make sure any
existing files in $HOME
are removed before you run stow
. stow
is
conservative and doesn't override preexisting files.