Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add oXygen as Diff & Merge Tool for Git Tower

Purpose

To register oXygen XML Editor's Diff & Merge Tools with Git Tower for macOS.

Screenshot showing Tower configured to use oXygen's Diff & Merge tools

Setup

  1. Click "Download ZIP" to download this gist to your computer. Double-click on the zip file to expand it.
  2. Copy the files in this gist to ~/Library/Application Support/com.fournova.Tower3/CompareTools/. (Paste this path into "Finder > Go > Go to Folder".)
  3. Open Terminal and enter:
    cd ~/Library/Application Support/com.fournova.Tower3/CompareTools/
    chmod +x oxygen-dir.sh oxygen-file.sh
  4. Restart Tower.
  5. In "Preferences > Git Config", set "Diff tool" to "oXygen Directory Diff", select the "Perform directory diff" checkbox, and set "Merge tool" to "oXygen File Diff".

Usage

In Tower, use the ⌘ + ⇧ + D keyboard shortcut (or "Repository > Open Diff Tool") to open a changeset in the oXygen Diff Directories app. Quit Diff Directories when finished.

When resolving a conflict in Tower, oXygen's Diff Files app will be opened. Quit Diff Files when finished.

Known Issues

Tower can only open one instance of the oXygen Directories/File Diff tools at a time, so before a new changeset can be viewed, the Diff app must be quit. Otherwise, changesets will be queued.

References

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>ApplicationIdentifier</key>
<string>ro.sync.exml.DiffDirs</string>
<key>ApplicationName</key>
<string>Diff Directories</string>
<key>DisplayName</key>
<string>oXygen Directory Diff</string>
<key>LaunchScript</key>
<string>oxygen-dir.sh</string>
<key>Identifier</key>
<string>oxygen-dir</string>
<key>SupportsMergeTool</key>
<false/>
<key>SupportsDiffChangeset</key>
<false/>
</dict>
<dict>
<key>ApplicationIdentifier</key>
<string>ro.sync.exml.DiffFiles</string>
<key>ApplicationName</key>
<string>Diff Files</string>
<key>DisplayName</key>
<string>oXygen File Diff</string>
<key>LaunchScript</key>
<string>oxygen-file.sh</string>
<key>Identifier</key>
<string>oxygendiff</string>
<key>SupportsMergeTool</key>
<true/>
<key>SupportsDiffChangeset</key>
<false/>
</dict>
</array>
</plist>
#!/bin/sh
LOCAL="$1"
REMOTE="$2"
# Sanitize LOCAL path
if [[ ! "$LOCAL" =~ ^/ ]]; then
LOCAL=$(echo "$LOCAL" | sed -e 's/^\.\///')
LOCAL="$PWD/$LOCAL"
fi
# Sanitize REMOTE path
if [[ ! "$REMOTE" =~ ^/ ]]; then
REMOTE=$(echo "$REMOTE" | sed -e 's/^\.\///')
REMOTE="$PWD/$REMOTE"
fi
BACKUP="/tmp/$(date +"%Y%d%m%H%M%S")"
APPLICATION_PATH="/Applications/Oxygen XML Editor"
if [ ! -d "$APPLICATION_PATH" ]; then
APPLICATION_PATH=/Volumes/$(osascript -e "path to application \"Diff Dirs\" as text" | sed 's/:/\//g')
fi
if [ ! -d "$APPLICATION_PATH" ]; then
echo "Could not find Diff Dirs. Please make sure you have installed a recent version of Diff Dirs." >&2
exit 128
fi
CMD="$APPLICATION_PATH/diffDirs.sh"
"$CMD" "$LOCAL" "$REMOTE"
exit 0
#!/bin/sh
LOCAL="$1"
REMOTE="$2"
# Sanitize LOCAL path
if [[ ! "$LOCAL" =~ ^/ ]]; then
LOCAL=$(echo "$LOCAL" | sed -e 's/^\.\///')
LOCAL="$PWD/$LOCAL"
fi
# Sanitize REMOTE path
if [[ ! "$REMOTE" =~ ^/ ]]; then
REMOTE=$(echo "$REMOTE" | sed -e 's/^\.\///')
REMOTE="$PWD/$REMOTE"
fi
MERGING="$4"
BACKUP="/tmp/$(date +"%Y%d%m%H%M%S")"
APPLICATION_PATH="/Applications/Oxygen XML Editor"
if [ ! -d "$APPLICATION_PATH" ]; then
APPLICATION_PATH=/Volumes/$(osascript -e "path to application \"Diff Files\" as text" | sed 's/:/\//g')
fi
if [ ! -d "$APPLICATION_PATH" ]; then
echo "Could not find Diff Files. Please make sure you have installed a recent version of Diff Files." >&2
exit 128
fi
CMD="$APPLICATION_PATH/diffFiles.sh"
if [ -n "$MERGING" ]; then
BASE="$3"
MERGE="$4"
# Sanitize BASE path
if [[ ! "$BASE" =~ ^/ ]]; then
BASE=$(echo "$BASE" | sed -e 's/^\.\///')
BASE="$PWD/$BASE"
if [ ! -f "$BASE" ]; then
BASE=/dev/null
fi
fi
# Sanitize MERGE path
if [[ ! "$MERGE" =~ ^/ ]]; then
MERGE=$(echo "$MERGE" | sed -e 's/^\.\///')
MERGE="$PWD/$MERGE"
if [ ! -f "$MERGE" ]; then
# For conflict "Both Added", Git does not pass the merge param correctly in current versions
MERGE=$(echo "$LOCAL" | sed -e 's/\.LOCAL\.[0-9]*//')
fi
fi
sleep 1 # required to create different modification timestamp
touch "$BACKUP"
"$CMD" -ext "$LOCAL" "$REMOTE" "$BASE" "$MERGE"
else
"$CMD" -ext "$LOCAL" "$REMOTE"
fi
if [ -n "$MERGING" ]; then
# Check if the merged file has changed
if [ "$MERGE" -ot "$BACKUP" ]; then
exit 1
fi
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.