SourceTree 1.3’s new ‘Custom Actions’ feature lets you extend the range of actions you can perform from within the GUI, effectively adding your own commands. Maybe you have scripts that you’d like to call, or external tools that you’d like to use beyond what SourceTree already allows for – Custom Actions are the way to go.
As a simple example, let’s say you use TextMate for editing files in a project, and you wanted to assign a keyboard shortcut to open the root of the repository in TextMate? SourceTree doesn’t provide an in-built option for that, so let’s add it using Custom Actions.
Firstly, open the Preferences window, and select the ‘Custom Actions’ tab:
Click ‘Add’, and fill in the details as follows (to fill in the keyboard shortcut, just lick on the shortcut area and type a keyboard combination):
Notice how all I had to do was specify the location of the script I wanted to run, and then give it some parameters – in this case ‘$REPO’ which is the path to the repository.
After I click OK, an ‘Open in TextMate’ option will appear on the top-level Actions menu under the Custom Actions section:
Or, I can just press Shift-T to open my repository in TextMate whenever I want.
If you use the $FILE or $SHA parameters, then these will cause the action to appear on context menus associated with files or commits, and will pass that context to the command. So for example you could have a deployment script which took the $SHA parameter, then right-click on a commit and run your deployment script for that specific commit right from within SourceTree.
Custom Actions are a great new way to extend SourceTree to work with your own scripts and tools, and improve your productivity!