Use RubyMine as diff and merge tool for Tower

Juraj Kostolanský April 22, 2021

As a Ruby on Rails developer, I’m currently using RubyMine from JetBrains as my primary IDE and Tower to work with git more productively.

Tower allows me to view diffs as well as solve merge conflicts right from within the interface. However, it often makes sense to use a dedicated diff or merge tool — for comparing differences between two git branches or solving complex merge conflicts.

Tower supports direct integrations for a lot of diff and merge tools for these jobs. You can just select the right application in the Tower’s preferences, and then you can easily launch that external tool right from the Tower interface.

What you might not know is that RubyMine has a pretty nice built-in diff and merge tool you can use for this purpose with just a little bit of custom setup. Here’s how.

In RubyMine, install the CLI by selecting Tools - Create Command-line Launcher in the menu.

RubyMine CLI

This will allow you to run the mine command to launch RubyMine from the terminal. We will use that in the next step.

Create the following file:

~/Library/Application Support/com.fournova.Tower3/CompareTools/rubymine.sh

With this content:

#!/bin/bash

if [ "$#" -eq 4 ]; then
    mine merge "$1" "$2" "$3" "$4"
else
    mine diff "$1" "$2"
fi

This will choose the proper command based on the number of arguments provided by the Tower application. The mine diff and mine merge commands will run RubyMine diff and merge tools.

Don’t forget to change the file permissions for this new file:

chmod +x rubymine.sh

Also create this file:

~/Library/Application Support/com.fournova.Tower3/CompareTools/CompareTools.plist

With this content:

<?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>com.jetbrains.RubyMine</string>
      <key>ApplicationName</key>
      <string>RubyMine</string>
      <key>DisplayName</key>
      <string>RubyMine</string>
      <key>LaunchScript</key>
      <string>rubymine.sh</string>
      <key>Identifier</key>
      <string>rubymine</string>
      <key>SupportsMergeTool</key>
      <true/>
      <key>SupportsDiffChangeset</key>
      <true/>
    </dict>
  </array>
</plist>

This tells Tower how to use that rubymine.sh file. You should now be able to choose RubyMine in the Tower preferences.

Tower Preferences

RubyMine also supports directory diffs, so you should select that option.

And that’s it! You can now use RubyMine as an external diff and merge tool right from the Tower user interface.

RubyMine diff tool

Let's stay in touch

Do you like what you read? Subscribe to get my content on web development, programming, system administration, side projects and more. No spam, unsubscribe at any time.