Hi guys,
I wanted to have a "Diff From" and "Diff To" option within my Eclipse IDE (Linux), for occasions when I want to compare two open files within my IDE (ie, focus on one file, select "Diff From", focus on the other file and select "Diff To").
I was pondering the following approach:
Is this the way to go? Or are there smarter/better ways to go about this?
--------------------
Because I was in a bit of a hurry for this, I've gone ahead and done it this way, will share the steps I've got, in-case others need this.
You should now be able to see the "Diff From" and "Diff To" commands in the menus as below: (Run >> External Tools)

If you are a keyboard jockey, you will notice that you can trigger these actions from the keyboard quite easily via:
Usage Example
So... Here's how I make use of this in my scenario. I have two files open in Eclipse that appear to have similar content:

Beyond Compare then will appear showing the two files compared side-by-side. While viewing this diff, you can modify either side to suit your merging needs, save your changes, close BC3, and then your changes will appear in Eclipse, very nice

(Apologies for the large pics expanding the width of your frame. Thought it looked better than those tiny thumnails though)
I wanted to have a "Diff From" and "Diff To" option within my Eclipse IDE (Linux), for occasions when I want to compare two open files within my IDE (ie, focus on one file, select "Diff From", focus on the other file and select "Diff To").
I was pondering the following approach:
- I'll add two "External Tools" commands that will call two bash-script files "bc_diff_from" and "bc_diff_to".
- The "bc_diff_from" can save the file-path of the 1st file into a temp-file somewhere
- The "bc_diff_to" can use the previously saved 'from' path and the current 'to' path to run: bcompare $(from_path) $(to_path)
Is this the way to go? Or are there smarter/better ways to go about this?
--------------------
Because I was in a bit of a hurry for this, I've gone ahead and done it this way, will share the steps I've got, in-case others need this.
- Create the following two bash-scripts in your "~/bin" folder (which is hopefully already in your system's path, if not, add it).
bc_diff_from
Code:#!/bin/bash echo $1 > $HOME/bc.tmp
bc_diff_to
Code:#!/bin/bash FROM_PATH=`cat $HOME/bc.tmp` bcompare "$FROM_PATH" "$1"
- In Eclipse, go to: "Run >> External Tools >> External Tools Configurations..."
- In the left-pane, click on the "Program" item, then click the "New launch configuration" button in the top-left corner.
- On the "Main" tab, set the following details:
- Name: Diff From
- Location: /home/gurce/bin/bc_diff_from (use your bin path instead)
- Arguments: "${selected_resource_loc}" (quotes are essential - to handle paths with spaces)
- On the "Common" tab:
- In the "Display in favourites menu", check the "External Tools" checkbox
- Click the "Apply" button to save these settings
- Click the "New launch configuration" button in the top-left corner again.
- On the "Main" tab, set the following details:
- Name: Diff To
- Location: /home/gurce/bin/bc_diff_to (use your bin path instead)
- Arguments: "${selected_resource_loc}" (quotes are essential - to handle paths with spaces)
- On the "Common" tab:
- In the "Display in favourites menu", check the "External Tools" checkbox
- Click the "Apply" button to save these settings
You should now be able to see the "Diff From" and "Diff To" commands in the menus as below: (Run >> External Tools)
If you are a keyboard jockey, you will notice that you can trigger these actions from the keyboard quite easily via:
- Diff From: Alt+R, E, 1
- Diff To: Alt+R, E, 2
Usage Example
So... Here's how I make use of this in my scenario. I have two files open in Eclipse that appear to have similar content:
- I focus on my 1st file "egm_touchscreen.c" and type: "Alt+R, E, 1" (Diff From)
- I focus on my 2nd file "itable_touchscreen.c" and type: "Alt+R, E, 2" (Diff To)
Beyond Compare then will appear showing the two files compared side-by-side. While viewing this diff, you can modify either side to suit your merging needs, save your changes, close BC3, and then your changes will appear in Eclipse, very nice

(Apologies for the large pics expanding the width of your frame. Thought it looked better than those tiny thumnails though)
Comment