clock menu more-arrow no yes mobile

Filed under:

Integrate GitHub with Sublime and save some time

When I write or edit code in Sublime Text, push to GitHub, and want to share that code with a colleague, I often spend a good chunk of time trying to find that file and particular line(s) I want to reference in our repository. Typically, this is what I do:

  1. Look at where I'm at in my local project in Sublime.
  2. Go to a browser, navigate to GitHub.
  3. Find the repo.
  4. Find the file.
  5. Find the line(s).
  6. Highlight the line(s).
  7. Copy the URL, paste and send to colleague.

This is fine, right? It's not exactly the end of the world, but when you are working with an incredibly complex and large codebase with what seems to be an endless number of directories and models (cough, like our Chorus codebase), this can become a very meticulous task, especially when you have to do it multiple times a day.

The other day I stumbled across a neat Sublime Text package called Sublime GitHub that eases the pain of tasks like these and more. This package allows you to highlight lines in Sublime, type a command into the Command Palette, and automatically takes you to that particular line(s) in the remote repo.


Here is a project. Let's say I want to share lines 41-42 with someone to look over the color palette I've chosen for my chart.

With the GitHub Sublime package, I would highlight those lines, then press Shift+Command+P to open up the Command Palette, and find the "GitHub: Open Remote URL in Browser" command, and hit Enter.

Doing so takes me right to my repo, to the correct file, with those lines already highlighted for me!:

If you'd like to be a total superstar, press "y" on your keyboard after you get to this page. This will give you a canonical URL to the file, meaning it will show that particular version (since by the time someone sees this, that file may have undergone revisions).

That saved me a good minute or so, and I'm pretty happy. The package has other handy commands included, such as creating and working with Gists and viewing commit history.

How to Install

First, make sure you have the Sublime Package Control plugin. Then open "Package Control: Install Package" in your Command Palette and search for "sublime-github". That's it!

Here's a link to the plugin's repo for more info on what it can do.