Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 234
user93353 Avatar asked Jul 25 '17 06:07

user93353


2 Answers

This is an old question, but if someone else is looking for the answer currently the easiest way to accomplish this is to follow these steps

  1. Within SourceTree go to Tools -> Options
  2. Click Custom Actions
  3. Click Add
  4. Add the Caption
  5. For script to run, hit the three dot button and locate the .exe of the application you are wanting to open the file in
  6. Add the needed parameters to the parameters text box (in my case this is $FILE
  7. Click OK
  8. Restart SourceTree

New custom action window

Now if you right click on a file in Sourcetree and go to the custom actions menu it will now have the action you created. Click on it and it will open in the application you selected without keeping the progress bar open for no reason.

like image 112
dmoore1181 Avatar answered Nov 15 '22 13:11

dmoore1181


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.

like image 1
zzxyz Avatar answered Nov 15 '22 15:11

zzxyz