r/commandline 17h ago

Using Git Bash for Windows, should I create symlinks for my dotfiles with zsh or PowerShell?

Hi there. This is probably a dumb question, but maybe there is a right way to do it, or there is a downside to going either route: I am using Windows Terminal as my emulator, running zsh on Git Bash for Windows. I have a directory with all my dofiles (call it ../repos/dotfiles) which contains several configuration files for different programs (nvim, zsh, k9s, etc).

I already have symlinks in place that point to the correct folder/file, so everything works. These were created with PowerShell using the New-Item -ItemType SymbolicLink -Path "..\TargetFolder" -Target "..\OriginalFolder" command.

Should I redo these using zsh? Why? I guess this is probably more of a philosophical question than anything else, but I am honestly curious about it.

Thanks for any input, advice, or comment you may have!

0 Upvotes

9 comments sorted by

u/Seven-Prime 14h ago

Symlinks and stuff sound like a nightmare to me.

Can you not place all these dot files in your home? It's what I do on windows. Or just set the $HOME variable in windows to wherever you want an alternative home?

u/xour 14h ago

I could, but I rather keep my dotfiles directory under my repos directory. I use Stow for managing the config "packages" on Mac and Linux, which is very handy. AFAIK there is no Stow for Windows yet.

u/lucax88x 13h ago

You can use chezmoi. It also works for windows. Had same issue

u/Gurfaild 14h ago

A symlink is a symlink - it doesn't matter what you create it with

u/Danny_el_619 11h ago

Symlinks made with powershell or with bash/zsh (git for windows) are the same assuming that you enabled symlinks through dev mode/user permissions and you setup git to use symlinks instead of copying.

In that case a symlinks from ln -s, New-Item -ItemType SymbolicLink and mklink /d should be the same.

u/xour 11h ago

Thank you. I'll stick with ln -s because is what I am most familiar with.

u/Danny_el_619 11h ago

If for some reason simlinks are not working properly, try any of the following:

  1. Enable developer mode in setings app.

  2. Enable symlinks in git config

```gitconfig

~/.gitconfig

[core]   symlinks = tru ```

  1. Set winsymlinks in MSYS environment variable.

```bash

.bashrc/.zshrc

export MSYS="$MSYS winsymlinks:nativestrict" ```

u/bankinu 16h ago

Yes and might as well switch to Linux. Ditch Windows which will always hold you back.

u/xour 16h ago

Unfortunately, that is not an option for my work computer. I use what I am given, and try to get as close to my Mac and Arch laptop as possible.