Tuesday, August 8, 2017

SourceTree: Adding a custom action to open a file in an external editor

Leave a Comment

SourceTree has a window called unstaged files where it shows files whose changes have not been committed. I want to right click on the file name & open it in an external editor. So I added a custom action -> Edit -> pathtoeditor\editor.exe $REPO\$FILE.

This launches the editor. But SourceTree also keeps showing a progress bar. progress bar The progress bar closes only after I close the external editor.

How do I avoid this? After opening the file in the external editor, I want SourceTree's UI to return to its normal state without waiting for the editor to exit.

1 Answers

Answers 1

Make a .bat file, say..."launchNotepad.bat" like so

@call pathtoEditor\editor %1 

Make the batch file your script target, and your parameters stay as $REPO\$FILE. This'll make launching the editor your action, rather than the editor itself.

This has a few other advantages, like SourceTree picking up on updates to the batch file without having to restart it.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment