• Stars
    star
    464
  • Rank 94,450 (Top 2 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 10 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

diff images from the command line

spaceman-diff

diff images from the command line

what's insideβ„’

Important business programmers don't have time to switch away from their terminal to view the diff of an image they're about to commit. The three seconds it takes to open an external diff visualization program could drive your sales team to drink and make inappropriate remarks to your new employees. Increase your productivity bottom line today, with spaceman-diff!

spaceman-diff is a quick drop in to git-diff. The idea is that you can just git diff like normal and, if you've changed an image file, spaceman-diff will render your images in a colorful ASCII approximation in your shell along with helpful data like file size changes.

Here's a quick example of what you might see:

spaceman screenshot

The goal is that spaceman-diff gives you a quick way of verifying that yes, the image you're committing is the image you want to commit, and yes, the image you're committing isn't accidentally 20 terabytes in size or something foolish like that.

Note: right now, spaceman-diff requires a change in the image; you won't see a diff rendered if you're simply adding or removing a file to your repo. git diff apparently doesn't pass things through to spaceman-diff at all in this case. There's probably a way to handle this, so pull requests accepted.

dependencies

There are two dependencies that you need before you can fiddle with pixels and characters and junk: jp2a and ImageMagick. jp2a handles conversion of a JPEG to ASCII, and ImageMagick can do everything from image conversion to probably running a nuclear reactor.

os x

If you're using Homebrew, blindly run this:

brew install jp2a imagemagick

linux

If you're using apt, you should be able to install your dependencies in a similar manner:

sudo apt-get install jp2a imagemagick

install

Once you have your dependencies installed, drop spaceman-diff onto your system or your dotfiles directory or whatever kooky stuff you're using. If you're using Homebrew, you can instead install spaceman-diff with brew install spaceman-diff. After that, you need to configure Git to use spaceman-diff for all your image diffs.

If you don't have one already, create a file at ~/.config/git/attributes and add this to it:

*.png  diff=spaceman-diff
*.jpg  diff=spaceman-diff
*.jpeg diff=spaceman-diff
*.gif  diff=spaceman-diff

This basically tells Git to use the spaceman-diff strategy to render the diff for these four particular file extensions.

Next, you need to tell Git about spaceman-diff. Do that by editing ~/.gitconfig:

[diff "spaceman-diff"]
  command = /path/to/spaceman-diff

At this point, you should be ready to go. Try it out on a directory with an unstaged image change and run it with git diff.

contributing

Send a pull request with your changes, and make sure the tests pass. You can run dem tests with ./tests in your working directory.

cool

This was cobbled together by @holman.

More Repositories

1

dotfiles

@holman does dotfiles
Shell
7,037
star
2

spark

▁▂▃▅▂▇ in your shell.
Shell
5,968
star
3

boom

Motherfucking TEXT SNIPPETS! On the COMMAND LINE!
Ruby
1,269
star
4

extended-exercise-windows

A list of startups that have employee-friendly terms for exercising your options past 90 days.
1,136
star
5

ama

Ask @holman anything!
722
star
6

left

Left is a clean, whitespace-happy layout for Jekyll.
CSS
536
star
7

gifme

Fucking animations. You need them.
Ruby
321
star
8

bubs

β’·β“Šβ’·β’·β“β’Ίβ“ˆ
Ruby
178
star
9

bandwidth-friends

A shell script for macOS that makes sure you are being nice to your nice coffeeshop internet neighbors. πŸ’–
Shell
87
star
10

boastful

A jQuery plugin to trawl Twitter for people linking to you.
JavaScript
82
star
11

hopper

Collection, Analyzation, and BBQing of Ruby community statistics.
Ruby
80
star
12

eponine

A very simple web server interface to shell scripts. Designed for Slack integrations on a Raspberry Pi.
Shell
54
star
13

rapinoe

Parse Keynote files in Ruby.
Ruby
46
star
14

stars

Recent Favstar and Convore stars on your command line.
Ruby
38
star
15

fuck-yeah

fuck yeah nouns
JavaScript
37
star
16

fatigue

Import your Nike+ runs into Garmin Connect.
Ruby
32
star
17

facelette

FACEEEEETIMMEMMEMEMEE
Ruby
28
star
18

this-machine-rebases-branches

it does.
26
star
19

vagranception

BWWWAAAAAAAAAAA
Ruby
22
star
20

tissues

things.app + github issues
Ruby
21
star
21

holmalicious

My mom sends me recipes.
19
star
22

git-hooks

Installable git hooks, a place to collect them
19
star
23

.js

holman's dotjs scripts
JavaScript
19
star
24

shamazing

SHAMAZING HASH ANALYSIS
Ruby
18
star
25

play

Play has moved to:
16
star
26

keep

It makes keeping config information pretty easy.
Ruby
12
star
27

casual

A tiny CAS client for Ruby.
Ruby
6
star
28

two_adium_one_cup

conversation history consolidation for Adium
Ruby
5
star
29

noted

A tiny Rails note search for your beautiful mug, sweetie.
5
star
30

maliciousurl

MALICIOUS MALICIOUS MALICIOUS MALICIOUS
Ruby
4
star
31

holman

holman
Ruby
4
star
32

brightkitey

brightkitey is a cute little Ruby wrapper around Brightkite's API.
Ruby
4
star
33

leftright

Cool replacement for Test::Unit's TestRunner
Ruby
1
star