47

I want to set default file viewer in SourceTree. The current one now is Notepad which does not show line break properly (all codes are in one line).

Gama11
  • 31,714
  • 9
  • 78
  • 100
mmdc
  • 1,677
  • 3
  • 20
  • 32
  • Wow, I didn't even know you could open a source file for editing with SourceTree by clicking on the file item. That's great. Perhaps it should be an option on the pop-up menu (...)? – Ashley Aitken Apr 22 '17 at 15:37

4 Answers4

48

SourceTree uses the default "Open With" application like Explorer. As far as I know other than changing the default application used by each file extension you cannot change the behavior of the menu item in SourceTree.

However...

You can add a custom action to achieve the same result using Tools | Options, Custom Actions tab:

Adding a custom action

This will appear under the Custom Actions menu. As far as I know you cannot add a shortcut key to custom actions.

The SourceTree blog has more info.

Ade Miller
  • 13,575
  • 1
  • 42
  • 75
  • doesnt seem to work in my version, but still a good idea, and perhaps it will start working after a reboot ;-) – Peter Perháč Mar 13 '14 at 16:20
  • Great tip! I'm using this to open my files in the new Visual Studio Code editor. Super quick with great syntax highlighting! – Daniel Mackay May 03 '15 at 04:58
  • 1
    However - when I do it Mac OS (currnetn wersion of SourceTree) I don't see any action in 'Custom Actions' submenu. :( – Kamil Kiełczewski Apr 13 '16 at 12:17
  • [This comment](https://blog.sourcetreeapp.com/2012/02/08/custom-actions-more-power-to-you/#comment-1294576900) might help. – ricksmt May 18 '16 at 17:22
  • 13
    Helps but only works for opening current versions. Doesn't open the specific version of the file from a specific commit. – AnimaSola Dec 19 '16 at 18:28
  • 1
    Agree with AnimaSola. I was anticipating seeing the version of file from repository that I selected in the timeline. – Steven Edison Mar 02 '17 at 16:34
21

I had this same problem for my MacBook.

To have sourcetree Open selected version, or Open current version a file with your desired program, change the system-wide default app used to open the file type to your desired app:

  1. using Finder, find a file with the same file type that you are trying to open via SourceTree

    • TIP: if cannot find file with same file type, can create one via Terminal with command:

      touch file.filetype
      
  2. right click said file in Finder

  3. click Get Info
  4. expand Open With:
  5. use revealed drop-down menu to select desired app
  6. below the drop-down menu, click Change All...
  7. in the pop-up window, click Continue
  8. done!
  9. go to SourceTree and Open selected version, or Open current version that file :)

reference: https://www.laptopmag.com/articles/how-to-change-default-applications-mac

Eric
  • 16,397
  • 8
  • 68
  • 76
2

Inspired by Eric's answer, for Windows:

Open file explorer > right click any .py file > "open with" > "choose another app" > [your editor e.g. atom] > "always use this app to open .py files" (for python source files)

Then simply right click your file on SourceTree > "Open selected version"

ー PupSoZeyDe ー
  • 1,082
  • 3
  • 14
  • 33
1

For Macs, SourceTree uses your system's default file viewer for the file type that you open. For example if you double-click a .js file in SourceTree, it will use your Mac's default file viewer for JavaScript files.

In SourceTree the fastest way to change the default file viewer for the file you want is to:

  1. Right-click the file and select "Show In Finder"
  2. In Finder right-click the file and select "Get Info" (or use keyboard shortcut Cmd-i)
  3. Look for the "Open with:" option and use the dropdown to select the program you want
  4. Click the "Change All..." button to update the default program for all files of this type
  5. Click the "Continue" button to save

Once you make this change SourceTree will open the file with the program you just selected.

Growth Mindset
  • 1,135
  • 1
  • 12
  • 28