Whenever I press Ctrl + S in eclipse to save source code I want some custom CMD on shell to run on my CentOS host. How can I do that?
Your best bet is to add an external builder to your project. You can choose to run an ant script or an arbitrary program (like /bin/bash) with arguments of your choice. Every time a project resource is saved (like a file) your builder will be run. See Ant Project Builders for a discussion on external builders.
The Java Editor has Save Actions that can be activated and customized, but AFAIK they don't include the ability to run a program. See Preferences > Java > Editors
.
If you can write plugins, you can also add an org.eclipse.core.commands.IExecutionListener
to the org.eclipse.ui.commands.ICommandService
and listen for the Save command (org.eclipse.ui.IWorkbenchCommandConstants.FILE_SAVE
). Then you can do anything that you can write in java. But the external project builders are probably the fastest way to what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With