GithubHelp home page GithubHelp logo

cleandiff's Introduction

CleanDiff

(A better way to diff)

Simplified diffing of files.

CleanDiff removes the unnecessary noise from diffs so that your brain can focus on the important bits.

Pass it any two files, or use it in conjunction with git diff or git difftool

Example

Imagine you add a few words to a file, then want to see the diff. The screenshot below shows how nigh-impossible it is to see what's changed when you use diff. Kaleidoscope definitely improves on the situation, but CleanDiff makes it even clearer.

Adding text

Changing text

(as opposed to just adding it)

CleanDiff can show you what's been removed, in addition to what's been added. In the example below I changed a couple words in the previous text. The output from diff and Kaleidoscope look very similar to the screenshot above.

WARNING - ๐ฐ software

This app, while stable, and safe, is still rough around the edges. It should work fine on OS X and Linux, but not Windows.

Geek instructions

Installation

CleanDiff currently requires 2 *nix utilities which most of you are unlikely to have installed: dwdiff and aha. On OS X we'd recommend you install them via Homebrew.

# on OS X (after Homebrew has been installed)
$ brew install dwdiff
$ brew install aha

Linux people should use whatever the package manager is for your distro.

Next up, fork this repo, then clone it locally:

$ git clone https://github.com/<your username>/cleandiff.git
# or
$ git clone [email protected]:<your username>/cleandiff.git


# For those who don't feel like forking, or don't have GitHub accounts
# (Luddites!)

$ git clone https://github.com/masukomi/cleandiff.git
# or
$ git clone [email protected]:masukomi/cleandiff.git

and add the cdiff executable to your $PATH.

# at the bottom of your ~/.bashrc or ~/.bash_profile
PATH=$PATH:/path/to/cleandiff/folder

Please note. The Term::AnsiColor gem installs a script called cdiff at /usr/bin. If you've installed this then you'll want to make sure that cleandiff's directory comes before /usr/bin in your path, or just get rid of their cdiff because really, why would you need it when you've got this?

Configuration

Until CleanDiff has it's own GUI front-end (we're working on that) you'll have to make a choice of where you'd like to see the output.

Your choices are:

  • Your favorite web browser
  • Your favorite text editor (probably)

You'll also need to tell git how to use it as a graphical difftool.


Configuring your favorite browser
At the bottom of the cdiff file you'll see some comments about Chrome, Safari, Firefox. Uncomment / tweak the one that makes you most smiley.


Configuring yor favorite text editor
cdiff generates files with ANSI escape codes for coloring, so you'll need to install the appropriate plugin in your favorite editor to enable support for colorizing text with ANSI escape codes. Without that it'll probably display the raw codes, and it'll look like poo (not litterally. There's no brown in our code.)

VIM:

First we need to enable filetype detection so that it'll automatically recognize .cdiff files (and thus enable us to auto-colorize them).

To do this just run the integration/vim_setup.sh script which will add a line to your ~/.vim/filetypes.vim and create a ~/.vim/ftdetect/cdiff.vim file.

Next install the Colorizer Plugin and add this to your ~/.vimrc

let g:colorizer_auto_filetype='cdiff'

Now that you've got Vim configured to handle files with ANSI escape codes, and it knows how to detect .cdiff files, you'll want to uncomment the appropriate line at the bottom of our cdiff script.

#MacVim
mvim $TEMP_FILE

Note / Rant
Unfortunately, when using this with git difftool it will open a new window for every file you're diffing, which sucks.

There's no real way to determine if your receiving one request for diffs in a series, or just one request, but in the future we can work to hack a solution by queueing up the requests to vim (and other editors) if they happen with very little time in between.

If you've got a better solution, please file an issue or Pull Request.

EMACS:

Instructions to follow as soon as an Emacs geek tells us how. ;)


Configuring Git

Configuring git is pretty simple. Just run the integration/git_setup.sh script.

And if you haven't done it already you'll really want to disable the prompting, because it's really annoying.

$ git config --global difftool.prompt false

While we're at it diffing with any git tool will be better for most folks with this

$ git config --global diff.algorithm patience

Usage

(bet you thought we'd never get here, eh?)

Usage without git

Pretty much the same as diff, only without any options.

$ cdiff path/to/file/a.txt path/to/file/b.txt

Usage with Git

If you've configured it as your default difftool then all you need to say is:

$ git difftool <anything you could pass to git diff>

#Ex.
$ git difftool HEAD^
$ git difftool fe0438
$ git difftool HEAD^..HEAD
# etc...

If you have not configured it as your default difftool then it's not very different. Just add in the --tool option like this:

$ git difftool --tool=cdiff <anything you could pass to git diff>

cleandiff's People

Contributors

masukomi avatar

Watchers

Don Wei avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.