Skip to content

Instantly share code, notes, and snippets.

@Zash
Created July 23, 2024 11:50
Show Gist options
  • Save Zash/921ba94de15c7415c57242fb7db26460 to your computer and use it in GitHub Desktop.
Save Zash/921ba94de15c7415c57242fb7db26460 to your computer and use it in GitHub Desktop.
git diff yaml with gron
*.json diff=gron
*.yaml diff=ygron
[core]
attributesfile = ~/.gitattributes
[diff "gron"]
textconv=gron
[diff "ygron"]
textconv=ygron.sh
#!/bin/sh
set -eu
# Ensure it's a valid yaml file and not a go template
if yq4 "$@" >/dev/null 2>/dev/null ; then
yq4 --output-format json "$@" | gron
else
cat "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment