Skip to content

Latest commit

 

History

History
103 lines (76 loc) · 3.76 KB

File metadata and controls

103 lines (76 loc) · 3.76 KB
permalink unixshell.html
layout default
mainAnchor unixShell
title visdiff
subtitle Command-line tool for launching VisualDiffer from the terminal

visdiff is a command-line tool bundled with VisualDiffer. It opens a comparison directly from the terminal without having to launch the app manually.

The executable is located at:

/Applications/VisualDiffer.app/Contents/Helpers/visdiff
visdiff [options] <left file or folder> <right file or folder>

Left and right must both be files or both be folders.

Option Description
--wait Block the terminal until the diff window is closed. Useful when calling visdiff from a script or editor that needs to wait for the comparison to finish before continuing.
--focus After the diff window is closed, return focus to the application that launched visdiff (for example, your terminal or editor). Only effective when used together with --wait.
--no-warning Suppress the sandbox warning printed to stderr on every run. Useful in scripts where the warning would pollute the output.
--version Print the visdiff version and exit.

--focus without --wait has no effect. The typical use case is integrating visdiff with an editor or script that needs to:

  1. open a diff,
  2. wait for the user to close it, and
  3. regain focus automatically when the diff window is closed.

{% highlight bash %} $ visdiff --wait --focus ~/original.txt ~/modified.txt {% endhighlight %}

Without --focus, VisualDiffer keeps focus after the window closes. With --focus, focus returns to the calling application.

VisualDiffer does not install visdiff into a system path automatically (Apple's App Store guidelines do not allow it). You can create the link manually:

{% highlight bash %} $ sudo ln -s /Applications/VisualDiffer.app/Contents/Helpers/visdiff /usr/local/bin/visdiff {% endhighlight %}

visdiff runs inside the macOS sandbox. The first time it tries to open a path it has not seen before, VisualDiffer may prompt you to confirm access. To avoid repeated prompts, add the relevant paths in Settings → Trusted Paths. See Trusted Paths for details.

The sandbox also prints a reminder to stderr on every run. Pass --no-warning to silence it once you have set up your trusted paths.

Because visdiff is sandboxed, it cannot read the shell's current working directory directly. Relative paths are resolved against the sandbox container, not against $PWD, which means they will likely fail.

The fix is to prepend $PWD to make the path absolute before passing it to visdiff:

Instead of:

{% highlight bash %} $ visdiff ../myfile.txt ~/reference.txt {% endhighlight %}

Use:

{% highlight bash %} $ visdiff $PWD/../myfile.txt ~/reference.txt {% endhighlight %}