Skip to content

Instantly share code, notes, and snippets.

@zsusswein
Created April 15, 2026 14:37
Show Gist options
  • Select an option

  • Save zsusswein/16d28f5f7587ec8b13829d9930163a7c to your computer and use it in GitHub Desktop.

Select an option

Save zsusswein/16d28f5f7587ec8b13829d9930163a7c to your computer and use it in GitHub Desktop.
gdiff-html: View difftastic git diffs as dark-mode HTML in the browser (Catppuccin Mocha)
# gdiff-html: View difftastic git diffs as dark-mode HTML in the browser
# Usage: gdiff-html [git diff args...]
# Examples:
# gdiff-html # diff working tree vs HEAD
# gdiff-html develop # diff working tree vs develop
# gdiff-html main..feature # diff between branches
# gdiff-html --staged # diff staged changes
gdiff-html() {
local out="$HOME/diff.html"
GIT_EXTERNAL_DIFF="difft --color=always" git diff "$@" | aha --no-header | \
{ printf '<!DOCTYPE html><html><head><meta charset="utf-8"><style>
body { background:#1e1e2e; color:#cdd6f4; font-family:"Fira Code","Cascadia Code",Menlo,monospace; font-size:14px; padding:2em; white-space:pre-wrap; }
span[style*="color:red"] { color:#f38ba8 !important; filter:none !important; }
span[style*="color:green"] { color:#a6e3a1 !important; filter:none !important; }
span[style*="color:olive"] { color:#f9e2af !important; filter:none !important; }
span[style*="color:yellow"] { color:#f9e2af !important; filter:none !important; }
span[style*="color:blue"] { color:#89b4fa !important; filter:none !important; }
span[style*="color:purple"], span[style*="color:magenta"] { color:#cba6f7 !important; filter:none !important; }
span[style*="color:cyan"] { color:#94e2d5 !important; filter:none !important; }
span[style*="color:dimgray"] { color:#6c7086 !important; filter:none !important; }
span[style*="font-weight:bold"][style*="color:red"] { color:#f38ba8 !important; font-weight:bold; filter:none !important; }
span[style*="font-weight:bold"][style*="color:green"] { color:#a6e3a1 !important; font-weight:bold; filter:none !important; }
</style></head><body><pre>'; cat; printf '</pre></body></html>'; } \
> "$out" && xdg-open "$out"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment