-
Hi, I'm having trouble figuring out how to use VSCode as the merge and diff tool for chezmoi. I have been able to write this configuration : merge:
# Based on https://code.visualstudio.com/docs/editor/command-line#_core-cli-options
command: code
args:
- --wait
- --merge
- "{{ .Destination }}" # Path 1
- "{{ .Target }}" # Path 2
- "{{ .Source }}" # Base
- "{{ .Source }}" # Result/Output
# Destination: /home/webtroter/.zshrc
# Source: /home/webtroter/.local/share/chezmoi/dot_zshrc
# Target: /tmp/chezmoi-merge2812438473/.zshrc
diff:
command: code
args:
- --wait
- --diff
- "{{ .Destination }}"
- "{{ .Target }}" I believe my diff config is OK (since it's pretty simple), but I'm struggling with the merge tool config. I'm definitely not an advanced user of the vscode merge tool (especially the new three-way merge tool), so help here is appreciated. Right now, with this config, I'm not sure the merge is working correctly. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 19 replies
-
What is the output of: $ chezmoi merge --debug $TARGET where The |
Beta Was this translation helpful? Give feedback.
-
Have you found the correct way to write it ? I'm not entirely sure why, but VS Code does not open the 3-way merge window, but just opens 3 different files. |
Beta Was this translation helpful? Give feedback.
-
Here was the approach that worked for me given the following context:
Important My goal was to integrate dotfile differences from a second device into chezmoi. The direction of the merge I used may not be appropriate for your use case. GoalSelectively merge hunks from Challenges
BehaviorOn Windows,
SolutionSince the chezmoi variable Note As @anthonyjclark discovered this can easily be altered to work with other shells. Based on @anthonyjclark's feedback, this solution was altered to leverage bash-like .chezmoi.toml.tmpl fragment:
So we have 4 file handles to work with, we make a copy of the file chezmoi places at
After completing the merge in the vscode UI, the file in the chezmoi repo should be ready for commit and/or |
Beta Was this translation helpful? Give feedback.
-
Hello, just wanted to add a working example for diff:
command: "code"
args:
- "--wait"
- "--diff"
- "{{ `{{ .Destination }}` }}"
- "{{ `{{ .Target }}` }}"
merge:
command: "bash"
args:
- "-c"
- "cp {{ `{{ .Target }}` }} {{ `{{ .Target }}` }}.base && code --wait --new-window --merge {{ `{{ .Destination }}` }} {{ `{{ .Target }}` }} {{ `{{ .Target }}` }}.base {{ `{{ .Source }}` }}" Also, note that for the diff command, |
Beta Was this translation helpful? Give feedback.
This almost worked for me. I wanted to use it directly in my chezmoi.toml file, instead of in a template. Therefore i converted it into the following