IssueRaiser

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

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

github (SaaS)

Rewrite target paths

twpayneAug 19, 2022, 2:25 PM

## 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.

Comment on this issue