Texts | Christofer Sandin

01001100 00101101

Terminal: Manage dotfiles with Stow

If you have started reading this introduction, I assume you have a repository with your config files somewhere. Otherwise, I can’t figure out what piqued your interest. Since people spend years tweaking, personalizing, and modifying them to adapt to their preferred way of working, you might as well manage them with the same skill. Meet Stow.

Install Stow via brew install stow and then clone that repo into ~/dotfiles. The main idea is to use Stow to create symbolic links from these files into your home directory. You can do this manually, but you might as well use Stow.

Here is my current setup:

~/dotfiles (main*) » tree
.
├── aerospace
├── btop
├── editorconfig
├── eslint
├── eza
├── glow
├── helix
├── ideavim
├── neofetch
├── npm
├── nvim
├── prettier
├── README.md
├── stylelint
├── tmux
├── vim
├── wezterm
├── wtf
├── yazi
└── zsh

Here’s how my directory setup looks for ~/dotfiles/nvim and how I organized the folder structure under that folder to mimic where I want the files to end up in my home directory.

(You can imagine that the first folder ~/dotfiles/nvim, which represents the application’s name, also symbolizes the ~ directory when placing files.)

~/dotfiles (main*) » tree -a nvim
nvim
└── .config
    └── nvim
        ├── init.lua
        ├── lazy-lock.json
        └── lua
            ├── .luarc.json
            ├── keymaps.lua
            ├── options.lua
            ├── plugins
            │   ├── alpha.lua
            │   ├── auto-indent.lua
            │   ├── colors.lua
            │   ├── comments.lua
            │   ├── completions.lua
            │   ├── formatting.lua
            │   ├── git.lua
            │   ├── linting.lua
            │   ├── lsp-config.lua
            │   ├── lualine.lua
            │   ├── markdown.lua
            │   ├── neo-tree.lua.NOT-IN-USE
            │   ├── noice.lua
            │   ├── none-ls.lua.NOT-IN-USE
            │   ├── nvim-tmux-navigation.lua
            │   ├── oil.lua
            │   ├── telescope.lua
            │   ├── theme.lua
            │   ├── treesitter-textobjects.lua
            │   ├── treesitter.lua
            │   └── which-key.lua
            └── plugins.lua

Then, use stow to symlink files into ~ with stow nvim

To verify, let’s look at how the file system looks after this. Running tree -a config/nvim gives us the tree structure of the directory:

~ » tree -a .config/nvim
.config/nvim
├── init.lua
├── lazy-lock.json
└── lua
    ├── .luarc.json
    ├── keymaps.lua
    ├── options.lua
    ├── plugins
    │   ├── alpha.lua
    │   ├── auto-indent.lua
    │   ├── colors.lua
    │   ├── comments.lua
    │   ├── completions.lua
    │   ├── formatting.lua
    │   ├── git.lua
    │   ├── linting.lua
    │   ├── lsp-config.lua
    │   ├── lualine.lua
    │   ├── markdown.lua
    │   ├── neo-tree.lua.NOT-IN-USE
    │   ├── noice.lua
    │   ├── none-ls.lua.NOT-IN-USE
    │   ├── nvim-tmux-navigation.lua
    │   ├── oil.lua
    │   ├── telescope.lua
    │   ├── theme.lua
    │   ├── treesitter-textobjects.lua
    │   ├── treesitter.lua
    │   └── which-key.lua
    └── plugins.lua

Then, pick and choose which ones you like. Stow uses the same name as the folders you have in your repository:

This works well for me, and I do not have any more requirements for a solution like this. However, there are other, more complex solutions to the same problem, so feel free to explore other options if this seems a bit rudimentary for your taste.


References