I wanted to diff two files on my Mac. I can do this in BBEdit, but itโ€™s not super easy. You can open one, then the other, then highlight both and diff, or chโ€ฆ oh, you get it.

But thereโ€™s a command line version of BBEditโ€™s diff tool, bbdiff. TIL that you can run it like this...

bbdiff "path/to/file1.text" "path/to/file1.text"

Note that if you don't have bbdiff installed but you do have BBEdit installed, you just need to select the menu item BBEdit >>> Install Command Line Tools...

But how do you get the daggum full path to the files in the Finder?

Seems like it might've used to do this by default, but the Finder can be set to show the path to the file you've got selected in a footer.

  1. Open Finder
  2. Click View >>> Show Path Bar
  3. Profit.

And here's the extra trick: Right click the file in that bar and select Copy [filename] as Pathname and POOF, you've got the full path in your clipboard.


Now look, if you're comparing two files in the terminal, just type and tab-complete, no Finder funny stuff. I got it. But if you're comparing two files that are reasonably far apart, well, this is pretty fast.

So that's cool, but there's gotta be an easier way to set up a diff that ignores whitespace than this.

Near real-time update: There is.

Usage:  bbdiff [options] FILE1 FILE2

               --case-sensitive
               --flatten-folders
               --help
               --ignore-curly-quotes
               --ignore-spaces
               --ignore-extra-spaces
               --ignore-leading-spaces
               --ignore-trailing-spaces
               --resume
               --reverse
               --short-version, -V
               --show-identical-files
               --skip-shielded-folders
               --text-files-only
               --version, -v
               --wait, -w

(Would've been nice if there was a roll-up, --ignore-all-whitespace option, but beggars, choosers, and free mode users, etc. Near real-time update: That's exactly what --ignore-spaces does, idiot. I owe Rich several beers.)

bbdiff --ignore-spaces "path/to/file1.text" "path/to/file1.text"

(Wonder if that includes tabs? Preliminary results suggest it does not. Tabs will still be shown as diffs. I owe Rich one fewer beer.)

It'll likely never replace VIm as the "worst case text editing fallback" for me -- you know, when you're on a new box, suddenly have to code, and want to download one tool to do it quickly no matter what file type it is -- but wow, BBEdit has been a nice companion for almost thirty years now.

(Yes, with about 99.44% certainty, I really did use it the year it was released. vi was not as nice a companion for the first few years of our relationship, and I had a number of pico & nano dalliances before settling down.)

Labels: , ,