My goto editor these days is TextMate. (The recent 2.0 releases have been really great). Like many developers, I use git for source control. Most of the time I use git on the command line, but once in a while I'll open up a project in the very awesome, and very free SourceTree VCS Gui from Atlassian. To simplify opening a project in SourceTree when working from TextMate I added a command via TextMate's extremely simple and flexible Bundles. (Which, due to the simplicity and flexibility of bundle's in TextMate, just tromps on anything I've seen in any other text editor, sorry Sublime Text.).
First, you will need to install SourceTree. Once installed, launch it and select SourceTree > Install Command Line Tools to install the stree shell command.
To add the command to TextMate, do the following:
- In TextMate, go to Bundles > Edit Bundles
- Select the Bundle that you want to add your command to. I created one with my own name, but you can use existing ones.
- Hit [command]+N to open a dialog to Create a New Item
- In the Create New Item dialog choose Command
- In the sidebar, name it Open With SourceTree. Add your favorite key equivalent (I use [command]+. )
- Set Save to Nothing
- Set Input to Nothing
- Set Output to Discard
- In the script shell at the bottom enter the following:
#!/usr/bin/env bash if [ -d $TM_DIRECTORY ] ; then cd $TM_DIRECTORY elif [ -d $TM_PROJECT_DIRECTORY ] ; then cd $TM_PROJECT_DIRECTORY fi GIT_ROOT=$(git rev-parse --show-toplevel) if [ -d $GIT_ROOT ] ; then stree $GIT_ROOT fi