shortcut to Sourcetree in Mac OS Finder
Asked by Drew Dara-Abrams:

Is there an easy way to add a link to the Mac OS Finder toolbar that will open up SourceTree for the current folder (if it contains a git repo)? I've done this with Textmate and the terminal (shown below). The addition of a git GUI would complete the trifecta!

![](https://img.skitch.com/20111205-ce355f61428hrgisi627x3a64g.pnglus)


Answers:
author: Mike Brandehorst
body: It's simple to make an application with applescript and drop it to the finder toolbar.

```
on run	tell application "Finder"		set theFolder to (the folder of the front window as alias)		if (exists folder ".git" of theFolder) then			tell application "SourceTree"				activate				open theFolder			end tell		end if	end tellend run
```

But every time you get a "want to add to root" question.

Are there commandline options for SourceTree to just open a git folder?

comments: author: stevestreeting
body: The 'stree' command line tool will open the current directory or any paths it is given on the command line. You can install it using the menu option 'SourceTree \> Install Command Line Tools' on the direct download version of SourceTree, or get the supplemental binary for the App Store version from here <http://downloads.atlassian.com/software/sourcetree/SourceTreeAppStoreCmdLineToolInstaller.pkg>


author: Mike Brandehorst
body: ```
The command-line version:on run	tell application "Finder"		set theFolder to (the folder of the front window as alias)		if (exists folder ".git" of theFolder) then			set theFolder to quoted form of POSIX path of (the folder of the front window as alias)			do shell script "screen -dmS sourcetree-droplet bash -c \"cd " & theFolder & "; /usr/local/bin/stree\""		end if	end tellend runThis still opens "Create Bookmarks?" window.
```


author: Mike Brandehorst
body: The command-line version:

```
on run	tell application "Finder"		set theFolder to (the folder of the front window as alias)		if (exists folder ".git" of theFolder) then			set theFolder to quoted form of POSIX path of (the folder of the front window as alias)			do shell script "screen -dmS sourcetree-droplet bash -c \"cd " & theFolder & "; /usr/local/bin/stree\""		end if	end tellend run
```

This still opens "Create Bookmarks?" window.


author: Mike Brandehorst
body: ```
The command-line version:
```

```
on run	tell application "Finder"		set theFolder to (the folder of the front window as alias)		if (exists folder ".git" of theFolder) then			set theFolder to quoted form of POSIX path of (the folder of the front window as alias)			do shell script "screen -dmS sourcetree-droplet bash -c \"cd " & theFolder & "; /usr/local/bin/stree\""		end if	end tellend runThis still opens "Create Bookmarks?" window.
```


author: stevestreeting
body: If you don't have a bookmark for the opened repo then yes, you'll get an option to create a bookmark.


author: Martin Braun
body: Here is a good solution that contains an "Open in SourceTree" app that can be dragged and dropped in the toolbar of Finder:

![36919049-f5c33b0e-1e81-11e8-9c70-424d2e9ff753](https://community.atlassian.com/t5/image/serverpage/image-id/144463i537ECA9734F7D208/image-size/large?v=v2&px=999 "36919049-f5c33b0e-1e81-11e8-9c70-424d2e9ff753")

<https://github.com/kdabir/finder-buttons>


author: stevestreeting
body: In 1.3 if you right-click a folder in Finder and go to 'Services' there is an option 'Open In SourceTree'.

comments: author: Mike Brandehorst
body: True, but three clicks are needed, droplet only one.


author: Mike Brandehorst
body: I would like to know this too...

GitX has one, maybe get the sourecode there to build one for SourceTree.

<http://code.google.com/p/git-osx-installer/wiki/OpenInGitX>


author: Mike Brandehorst
body: I would like to know this too...

GitX has one, maybe get the sourecode here to build one for SourceTree:

<http://code.google.com/p/git-osx-installer/wiki/OpenInGitX>

![](http://git-osx-installer.googlecode.com/files/open-in-gitx.jpg)