Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How I use a single .zshrc file on macOS and Windows (WSL2)

说明与用途

作者通过将单个 .zshrc 文件存放在 Git 仓库并在 macOS 与 WSL2 中使用符号链接,来避免重复配置。

问题

Maintaining separate Zsh configuration files for macOS and Windows (WSL2) leads to duplication and inconsistency.

结果

The author now maintains one .zshrc file, reducing duplication and ensuring consistent aliases, functions, and plugins across macOS and WSL2.

工作流

  • 1. Create a Git repository to host the shared .zshrc file.
  • 2. Store the .zshrc in the repository root.
  • 3. On macOS, add a symlink: ln -s /path/to/repo/.zshrc ~/.zshrc.
  • 4. On WSL2, add a symlink: ln -s /mnt/c/path/to/repo/.zshrc ~/.zshrc (or place it in /etc/zsh/zshrc if system-wide).
  • 5. Commit and push changes to the repo whenever the configuration is updated.
  • 6. Pull the latest changes in both environments to keep them in sync.

证据

I use a single .zshrc file on macOS and Windows (WSL2).

来源

  • 记录日期: 2026-09-20T02:45:32.552Z