Skip to content

Instantly share code, notes, and snippets.

@podhmo
Last active March 27, 2021 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save podhmo/fdc261640fd044648e73e01c5d62b9cb to your computer and use it in GitHub Desktop.
Save podhmo/fdc261640fd044648e73e01c5d62b9cb to your computer and use it in GitHub Desktop.
## colorful word level highlight diff
# diff -u <> <> | cdiffhighlight
cdiffhighlight() {
SED=$(which gsed || which sed)
$SED 's/^- /\x1b[1;31m-/;s/^+ /\x1b[1;32m+/;s/^@/\x1b[1;36m@/;s/$/\x1b[0m/' | diff-highlight
}
{
"name": "foo",
"age": 20,
"type": "person"
}
{
"name": "bar",
"age": 21,
"type": "person"
}
default:
$(MAKE) -k diff cdiff
diff:
diff -u 000person.json 001person.json
cdiff:
. .bash_functions && diff -u 000person.json 001person.json | cdiffhighlight
@podhmo
Copy link
Author

podhmo commented Mar 27, 2021

# \x1b[31m かもしれない。git diffの場合はboldが付いていない。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment