mbrt / gmailctl

Declarative configuration for Gmail filters
MIT License
1.8k stars 73 forks source link

Support diffing with colordiff/delta/etc #371

Open dbarnett opened 10 months ago

dbarnett commented 10 months ago

Would it be possible to hook in external diff viewing tools like colordiff.org or https://dandavison.github.io/delta/ when printing config diffs?

Sometimes it's hard to read long diffs with a bunch of trivial churn to whitespace or ordering and a better diff visualizer would help a lot.

mbrt commented 10 months ago

I think this is a good idea. I don't really know if and when I'll have the time to implement it though.

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 30 days without activity. This will be closed in 7 days, unless you add the 'lifecycle/keep-alive' label or comment.

mbrt commented 9 months ago

Forgot to keep this open.

serban commented 5 months ago

For what it's worth, to get colored diff output I've used this little Fish shell function for years, and it gets the job done nicely:

function gd
  set --function diff (                                         \
      gmailctl diff                                             \
      | grep --invert-match --extended-regexp '^(@|---|\+\+\+)' \
      | string collect)
  echo -n "$diff" | bat --plain --language diff
  test -n "$diff" && confirm 'Apply?' && gmailctl apply --yes
end

You need bat and the confirm helper is:

function confirm --argument-names prompt
  read --function response --nchars 1 --prompt-str \
      (set_color brmagenta)"■ $prompt "(set_color yellow)
  test $response = y
end