-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly handling file paths with spaces in them in merge tool settings in .chezmoi.toml.tmpl
#4169
Comments
This feels like it should be a bug, but I can understand not wanting to make all template instantiations use the formatting functions (it's non-trivial to set up). However, I think that you can make this happen with: [merge]
command = "bash"
args = [
"-c",
"cp {{ `"{{ .Target }}"` }} {{ `"{{ .Target }}"` }}.base && code --wait --new-window --merge {{ `"{{ .Destination }}"` }} {{ `"{{ .Target }}"` }} {{ `"{{ .Target }}"` }}.base {{ `"{{ .Source }}"` }}",
] |
That did indeed work, thank you @halostatue! You have to change the outermost quotes to be single quotes (otherwise it gets interpreted as multiple strings). So this would be the correct thing to do: [merge]
command = "bash"
args = [
"-c",
'cp {{ `"{{ .Target }}"` }} {{ `"{{ .Target }}"` }}.base && code --wait --new-window --merge {{ `"{{ .Destination }}"` }} {{ `"{{ .Target }}"` }} {{ `"{{ .Target }}"` }}.base {{ `"{{ .Source }}"` }}',
] I'm going to leave this open though, since I think the documentation should be updated to make this adjustment clear. |
This is mentioned on the docs for Diff To avoid dealing with so much quoting, you can also use the available functions. For example, I simply use
|
@LeonardoMor appreciate the callout in the docs, but I tried that and it didn't work. I'll try it again just to verify. |
Using |
What exactly are you trying to do?
I'm trying to implement "Use VSCode as the merge tool" as described in the docs here: https://www.chezmoi.io/user-guide/tools/merge/
It doesn't work quite right when you try to use something like
chezmoi merge-all
to resolve your configuration on files that have paths with spaces in them, like~/Library/Application Support
on macOS. Or at least, I'm not sure why it's not working properly. When it executes the function in the documentation, it appears to be trying to diff multiple files (like~/Library/Application
andSupport/<file>
) that just straight up don't exist, and I'm assuming it's because of that space in the path.My
.chezmoi.toml.tmpl
currently looks like this:The
.chezmoi.toml
file that gets generated afterchezmoi init
seems correct to my eyes:I tried using the
quote
function (by adding| quote
everywhere, like{{ .Target | quote }}
), but it seems not to believe that it exists:How can I make sure that the paths that are passed to the
cp
/code
command in the documentation are properly escaped so that spaces are interpreted as part of the path for the.Destination
/.Source
/.Target
variables?Where else have you checked for solutions?
Output of any commands you've tried with
--verbose
flag$ chezmoi --verbose $COMMAND
Running `chezmoi --verbose merge-all didn't print anything to the console. Anything I should be doing here?
Output of
chezmoi doctor
Additional context
For background on how I got here, I was just checking out the Ghostty terminal, and its config is in
~/Library/Application Support
on macOS. I started managing the config file as part ofchezmoi
(viachezmoi add $HOME/Library/Application\ Support/com.mitchellh.ghostty/config
), which works fine, however I edited some settings directly in the file instead of viachezmoi
, so I decided to usechezmoi merge-all
to merge them. It's my first time using that command, and I wanted to use VSCode to do that diff instead ofvimdiff
, which led me to the aforementioned documentation page. Any help would be greatly appreciated! Thanks!The text was updated successfully, but these errors were encountered: