12

I would like to enhance Eclipse so that when I press a custom key combo--say Ctrl + Shift + E--then it will run a command on the current file (if my current buffer is foo.c then it will run `mycommand foo.c' in foo.c's directory).

Chandrayya G K
  • 8,719
  • 5
  • 40
  • 68
Nathan
  • 1,218
  • 3
  • 19
  • 35

2 Answers2

16

Open the External Tools Configuration dialog from the Run menu. Create a new configuration with the following settings.

Location: c:\mycommand.exe (alter to your needs)

Working directory: ${container_loc}

Arguments: ${resource_loc}

Under Prefrences->General->Keys you can setup a shortcut for "Run last launched external tool".

This should solve your problem.

Stefan Teitge
  • 716
  • 3
  • 10
  • 21
  • That works well enough, Stefan, thanks. One concern: if I want to have two different custom commands, I can't use them both. Furthermore, I have to remember which command I used last when I press the key combo, making the keyboard shortcut fairly useless in this case. Is there any way to do this that will let me assign a key combo to a specific action, or does Eclipse not let me do that? – Nathan Jul 12 '11 at 21:50
2

Also, make sure that your "resource" (foo.c) is selected. It happened to me that when testing the external tool and horizontally scrolling the output pane, the resource gets deselected. When you run the external tool again after probably having made changes to its configuration, Eclipse will pop up an error box about "empty variable" (e.g. ${resource_loc} ).

Günter
  • 119
  • 2
  • 7