Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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
share|improve this question
    
Run type diff and post the output. – Michael Homer yesterday
2  
    
@MichaelHomer Added. That does look right to me. – Ben Saufley yesterday
    
I don't know how you tell prezto not to do that, but worst case you can just hack it out. – Michael Homer yesterday
1  
IN FACT! I ran brew install colordiff and now diff runs colordiff, which is an actual diff-based thing. – Ben Saufley yesterday

2 Answers 2

up vote 4 down vote accepted

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. 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.

share|improve this answer
1  
Nailed it. Thanks Michael! – Ben Saufley yesterday
    
certainly a good example of the ills of global scope and naming collisions – Michael Durrant yesterday

I would use an function like this

$ diffit () {
command diff $1 $2
}

A function over an alias as there are parameters

Usage: diffit file1 file2

You could put it in your .bashrc
Personally I keep my collection of functions in .bash_functions and in .bashrc I have

test -f ~/.bash_functions.sh && . $_
share|improve this answer
    
Just make it command diff "$@". – Arthur2e5 yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.