Skip to content

Instantly share code, notes, and snippets.

@podhmo
Last active Mar 27, 2021
Embed
What would you like to do?
## 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