-
Notifications
You must be signed in to change notification settings - Fork 0
Setup
I use stow to manage my dotfiles so that I can clone and set them up easily on a new machine. You can read this blog if you want a guide on how to use it for dotfiles, but all you need to know to use it here is that it creates symlinks for you in the correct places pointing back to this repository.
To begin, first clone this repository. I recommend cloning it into a subdirectory of your $HOME, e.g. $HOME/.dotfiles, because my stow install script relies on stow's default behaviour of using the current directory as the stow directory (where the files come from) and the parent directory as the target directory (where the symlinks are installed). If you want to clone it somewhere else and want to use stow, I recommend looking at man stow first to see how it works as you'll need to modify the script a bit.
Before installing my dotfiles, please read install-dotfiles.sh here and modify the $dirs variable by commenting out the directories you DON'T want to install. Each entry corresponds to a directory in the top-level directory of this dotfiles repo, so you can see what dotfiles will be installed in each directory. To install, run
./install-dotfiles.sh
in the repo's root directory. Stow should warn you if any files will be overwritten, but you should double-check beforehand anyway. I also recommend doing a sanity-check after installing to make sure that all the dotfiles have been set up in the correct locations. E.g. if you've installed the nvim directory, I would run ls -al ~/.config and expect to see an entry like this:
lrwxrwxrwx. 1 limao limao 30 Nov 9 13:41 nvim -> ../.dotfiles/nvim/.config/nvim
Note: If some directory that you want to stow already exists in the target directory, stow might create a symlink for each of the files in that directory, instead of creating a symlink for the directory itself. This is typically not desired behaviour since new files added won't be symlinked. E.g. if ~/.config/kitty already exists, attempting to stow it may result in
LINK: .config/kitty/kitty.conf => ../../.dotfiles/kitty/.config/kitty/kitty.conf
LINK: .config/kitty/themes => ../../.dotfiles/kitty/.config/kitty/themes
instead of
LINK: .config/kitty => ../.dotfiles/kitty/.config/kitty
To prevent this from happening, just remove the directory before installing (in this case, run rmdir ~/.config/kitty), though of course check to make sure it is empty first.
Stow can also remove symlinks as well. You can do this with the same install script,
./install-dotfiles.sh --clean
which removes the symlinks corresponding to the directories in the same $dirs variable.
I have an install script here that installs oh-my-zsh plugins automatically to $ZSH_CUSTOM/plugins:
./install-omz-plugins.sh
Choose the plugins you want to add by adding their repo URLs to the $repos variable.