Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I handle different configuration paths on *nix and Windows with chezmoi?

Tags:

dotfiles

I want to use chezmoi (or any other dotfile manager). I followed the instructions and added my nvim config on Windows with chezmoi.exe add ~\AppData\Local\nvim. The resulting git repository has that very path in it. When I check it out on a *nix machine and apply it with chezmoi apply, it creates a directory just like that in my home folder. However, it is expected to be .config/nvim.

I thought, chezmoi etc are designed exactly for the purpose of managing dotfiles across diverse machines. How am I supposed to manage that scenario?

like image 628
Tim-Erwin Avatar asked Nov 04 '25 06:11

Tim-Erwin


1 Answers

I struggled with this myself. The official answer is not useful for something like neovim, where you have dozens of configuration files. So I ended up simply making a junction from ~/AppData/Local/Nvim to ~/.config/nvim.

To do this automatically, make a file with the name run_after__symlink-neovim-config_windows.ps1 to ~/.local/share/chezmoi:

If ($PSVersionTable.PSVersion.Major -Le 5 -Or $isWindows) {
    If (-Not (Test-Path $env:LOCALAPPDATA\nvim)) {
        New-Item -Path $env:LOCALAPPDATA\nvim -ItemType Junction -Value $env:USERPROFILE\.config/nvim
    }
}
like image 183
Jo Totland Avatar answered Nov 06 '25 01:11

Jo Totland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!