Kaleidoscope Command Line Tool

The Kaleidoscope ksdiff command line tool serves two main purposes:

  1. It acts as the driving force behind many other integrations, in particular with source control systems like git.
  2. It can be used directly to compare and merge any number of files

Installation

To install or remove, follow these instructions:

!

Command Line Tool Needs Attention

Review the ksdiff setup to see what needs changing.

1
Install the ksdiff command line tool Review the ksdiff command line tool The ksdiff tool is available on your PATH

Manual Installation

The automatic installation above requires an admin account. If you are not administrator of your Mac, but still want to use ksdiff, follow these steps for manual configuration. Show more…

The idea if to add (a link to) ksdiff to your PATH, so you can just enter ksdiff instead of typing the full path. The steps assume you are using the default macOS zsh shell. Otherwise adjust commands as needed.

1

Open Terminal (or similar). Terminal is located in /Applications/Utilities

2

Locate ksdiff (inside of Kaleidoscope) using Terminal. On typical macOS installations, apps are located in /Applications. In that case, you could locate it by:

cd /Applications/Kaleidoscope.app/Contents/MacOS
ls -l

The listing should show two entries, Kaleidoscope and ksdiff.

3

Open the .zprofile file with an editor, e.g. TextEdit. Kaleidoscope reads this file when checking your command line setup.

touch ~/.zprofile
open ~/.zprofile -a TextEdit
4

Add the directory containing ksdiff to your PATH. Paste the following line at the end of the file if Kaleidoscope is in the default location. Otherwise use the location you found in step 2 above. If you previously added Kaleidoscope to PATH in ~/.zshrc, move that line to ~/.zprofile instead of adding another.

export PATH="/Applications/Kaleidoscope.app/Contents/MacOS:${PATH}"
5

Quit TextEdit, confirm saving the changes.

6

Quit and reopen Terminal and Kaleidoscope. The following command shows which ksdiff your login shell finds. The path should point inside the Kaleidoscope app you use:

/bin/zsh -lc 'command -v ksdiff'

Usage Examples

Compare the text content two draft plain text documents with the final Word document:

ksdiff ~/Documents/Draft1.txt ~/Documents/Draft2.txt ~/Desktop/Final.doc

Merge conflicting changes between Draft1.txt and Draft2.txt into Merge.txt:

ksdiff --merge --output ~/Documents/Merge.txt ~/Documents/Draft1.txt ~/Documents/Draft2.txt

Pipe content into ksdiff using -. This command will compare an original LoremIpsum.txt file with one where all u characters have been replaced with v.

cat LoremIpsum.txt | sed "s/u/v/g" | ksdiff LoremIpsum.txt -

Process Substitution can help comparing the output of multiple other calls. The following sample will compare the output of sorting file1 with the output of sorting file2, without the need to store the sorted files somewhere.

ksdiff <(sort file1) <(sort file2)

Repeatedly send content into the same Kaleidoscope window using the -l option (and piping). The following command will show processes that consume at least 1% of CPU. Use multiple times to compare over time.

ps -crx -o%cpu,command | grep -e "^\s.[1-9]" | ksdiff -l "ps"