gmailctl icon indicating copy to clipboard operation
gmailctl copied to clipboard

Support diffing with colordiff/delta/etc

Open dbarnett opened this issue 2 years ago • 4 comments

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.

dbarnett avatar Nov 25 '23 17:11 dbarnett

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

mbrt avatar Nov 27 '23 12:11 mbrt

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.

github-actions[bot] avatar Dec 28 '23 03:12 github-actions[bot]

Forgot to keep this open.

mbrt avatar Jan 04 '24 14:01 mbrt

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

serban avatar May 02 '24 21:05 serban