Rewrite target paths
## Is your feature request related to a problem? Please describe. Some files are in different directories on different machines, for example user-installed fonts are in `~/.local/share/fonts` on Linux and `~/Library/Fonts` on macOS. It would be nice to have a way to handle these differences that is easier to use than [the current method](https://www.chezmoi.io/user-guide/manage-machine-to-machine-differences/#handle-different-file-locations-on-different-systems-with-the-same-contents). ## Describe the solution you'd like From [this comment](https://github.com/twpayne/chezmoi/issues/2138#issuecomment-1159313813), roughly it could look something like: 1. In your config file, you specify something like: ```toml [rewriteTargetPaths] "Documents" = "One Drive - {organization}/Documents" ``` 2. This would tell chezmoi that whenever it finds `Documents` in your source state it should replace it with `One Drive - {organization}/Documents` in the target state. 3. To handle machine-to-machine differences, there's the [existing config file generation mechanism](https://www.chezmoi.io/reference/special-files-and-directories/chezmoi-format-tmpl/) which we can use. So, for example, your config file template would look something like: ``` [rewriteTargetPaths] "Documents" = "One Drive - {{ registry "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal" }}" ``` (assuming the addition of a `registry`
Posted by twpayne on Aug 19, 2022, 2:25 PM
Tags
Related issues
- 2026 - Microsoft Office 365
- [Ubuntu] `ubuntu-latest` label will use Ubuntu 26.04 in November 2026
- Gamut mapping
- [Codex Desktop] Editing and resending a queued message triggers "App-server queued follow-up no longer exists"
- [Windows] ChatGPT 26.820.60940 fails with "invalid transport in mcp_servers.codex_app"; Beta 26.727.40816 works
- [BUG]: infinite loading of videos
Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments
github (SaaS)
2026 - Microsoft Office 365
[Ubuntu] `ubuntu-latest` label will use Ubuntu 26.04 in November 2026
Gamut mapping
[Codex Desktop] Editing and resending a queued message triggers "App-server queued follow-up no longer exists"
[Windows] ChatGPT 26.820.60940 fails with "invalid transport in mcp_servers.codex_app"; Beta 26.727.40816 works
[BUG]: infinite loading of videos
Restore GPT-5.6 Sol’s 372k Codex context window, or provide an opt-in setting
Codex Desktop for macOS repeatedly triggers `syspolicyd` / `trustd` CPU and memory runaway
Rewrite target paths
## Is your feature request related to a problem? Please describe. Some files are in different directories on different machines, for example user-installed fonts are in `~/.local/share/fonts` on Linux and `~/Library/Fonts` on macOS. It would be nice to have a way to handle these differences that is easier to use than [the current method](https://www.chezmoi.io/user-guide/manage-machine-to-machine-differences/#handle-different-file-locations-on-different-systems-with-the-same-contents). ## Describe the solution you'd like From [this comment](https://github.com/twpayne/chezmoi/issues/2138#issuecomment-1159313813), roughly it could look something like: 1. In your config file, you specify something like: ```toml [rewriteTargetPaths] "Documents" = "One Drive - {organization}/Documents" ``` 2. This would tell chezmoi that whenever it finds `Documents` in your source state it should replace it with `One Drive - {organization}/Documents` in the target state. 3. To handle machine-to-machine differences, there's the [existing config file generation mechanism](https://www.chezmoi.io/reference/special-files-and-directories/chezmoi-format-tmpl/) which we can use. So, for example, your config file template would look something like: ``` [rewriteTargetPaths] "Documents" = "One Drive - {{ registry "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal" }}" ``` (assuming the addition of a `registry`
Comments (0)
No comments yet. Start the discussion.