#StackBounty: #zsh #git #diff git diff: create custom function/macro to ignore comments

Bounty: 150

I have following function in zsh, which basically works as diff, but it ignores comments (lines starting with # or empty lines) when comparing files:

function cdiff() {
  local args=("${(M)@:#-*}")
  local files=("${@:#-*}")
  /usr/bin/diff -u $args <(grep -E -v '^(#|$)' $files[1]) <(grep -E -v '^(#|$)' $files[2])

I would like to have something similar for git diff, if possible having my own custom function/macro cdiff and use it as git cdiff.

When I use git cdiff, I would like to see only "real" changes, while ignoring comments and empty lines.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.