Skip to content

marcotrosi/diffee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

diffee

diffee is a commandline folder comparison tool that offers a variety of outputs.

Background

I'm very much used to Beyond Compare 4 at work, but they didn't provide a proper version for macOS and I also need something for the commandline. In the meantime Beyond Compare 5 was released. I wasn't able to find a commandline tool in my package manager to diff directories in a similar fashion. Then I searched on Github and there are many repos with names like cmpdir, dircmp or any other combination with the words [cmp|diff]+[dir(s)|folder(s)|tree(s)], but none of them provides screenshots or a good description, and from what I can tell they are not doing what I need. Therefore I created this tool with tools like Beyond Compare, icdiff, diff -y and tree in mind, hence the name diffee.

Disclaimer

This is the first and probably last time I used the Go language and I have no clue if I used it properly. The reason why I used it instead of C is because I wanted to use the charmbracelet libs for colored output and rendering the directory trees. Unfortunately lipgloss/tree has/had some bugs, so I decided to write my own tree renderer.

Overview

By default diffee does a static side-by-side comparison with a colored tree view. But it also offers a plain format (--plain) which is useful to pipe the text into the next command like xargs.

Demo

demo

demo.mp4

Usage

diffee [left_dir] <right_dir> [flags]

Compare left_dir to right_dir. If left_dir is omitted, the current working directory is used as left_dir.

Options

General

 Option          Description
-h/--help print help
-v/--version print version
--bash generate bash-completion script in CWD named diffee.bash
--zsh generate bash-completion script in CWD named diffee.zsh
--fish generate bash-completion script in CWD named diffee.fish

Control Input

 Option           Description
-a/--all don't ignore dotfiles
-D/--depth limit depth, 0 is no limit and the default
-I <regex>/--include <regex> include matching paths into diff
can be used multiple times
if --include and --exclude are used together then --include is applied first
-E <regex>/--exclude <regex> exclude matching paths from diff
can be used multiple times
if --include and --exclude are used together then --include is applied first

Control Output

 Option              Description
-d/--diff show only files that differ
-m/--same show only files that are the same
-f/--files show only files
-F/--folders show only folders
-e/--no-empty do not show empty folders
-o/--orphans show only orphans
-O/--no-orphans do not show orphans
-l/--left-orphans show only left orphans
-r/--right-orphans show only right orphans
-y/--left-younger show only younger/newer files left
-Y/--right-younger show only younger/newer files right
-b/--left-bigger show only bigger files left
-B/--right-bigger show only bigger files right
-p/--plain print differences in plain format
use --single-quotes/-q or --double-quotes/-Q to wrap in quotes
useful in combination with xargs
-q/--single-quotes wrap plain output in single quotes
-Q/--double-quotes wrap plain output in double quotes

Control Comparison

 Option        Description
-s/--size compare file size
-t/--time compare modification time
-c/--crc32 compare CRC32 checksum

Control Display

 Option            Description
-x/--swap swap sides
-n/--info print file diff info
-C/--no-color turn colored output offoverwrites NO_COLOR
-L <string>/--left-alias <string> display the given string as left root folder name
-R <string>/--right-alias <string> display the given string as right root folder name

Building diffee

go build

ToDo

Improvements

  • improve filtering logic and information display
  • how to handle big depths that don't fit on screen?
  • Maybe the performance can be improved by using multi-threading?

Features

  • config file and/or env vars for default flags and colors - only if user feedback demands it
  • second --all or --All/-A to also not skip .git folders?
  • -I like --respect-vcs-ignore (see fd / rg options)
  • ignore casing on Windows if ever supported, highlight orange if different
  • ignore casing -i/-c. (short option name already in use)
  • create diff report (html, pdf)
  • --interactive/-i interactive mode to bring it much closer to Beyond Compare.
    • has to use some kind of view/window in case the tree doesn't fit on its half side
    • copy
    • delete
    • exclude
    • orphans
    • non-orphans
    • open file diff view
    • compare to
    • set as root
    • navigate tree
    • open/close folders
    • swap sides
    • --filediffcmd="icdiff {} {}" and/or config/env var