Causing `diff` to run `git diff`

aliasdiff()osxpreztozsh

I'd like to use diff as described here and in the documentation I see when I type man diff. However, when I type diff, what I get is this:

~ ❯❯❯ diff
usage: git diff --no-index <path> <path>

Similarly when I try to use diff, I get git errors because -rq is supported in man diff but not by git diff:

~ ❯❯❯ diff -rq ~/ ~/Desktop
fatal: invalid diff option/value: -rq

I'm using Prezto and hub which both help with git productivity, but neither creates an alias that doesn't at least start with g, as far as I can tell.

I've run a few scripts like this to try to find something that's defining diff to git diff but to no avail.

How do I fix this/find what's causing it/override it?

Edit

Ran type diff:

diff is a shell function
diff is /usr/bin/diff

Best Answer

This seems to be from prezto defining a function overriding diff. It may well have a way of disabling that, but I don't know what it is (but ericbn does!). You have a few options:

  • /usr/bin/diff or command diff will both run the diff command, rather than the function.
  • unset -f diff will remove the diff function. You could put that in your shell configuration.
  • As you've found, if colordiff is installed it will be used in preference to git diff by the function.
  • Finally, you can remove or rename the function from that file itself.

This really seems like a misfeature in prezto.