Skip to content

Instantly share code, notes, and snippets.

@dgtized
Last active December 27, 2015 08:39
Show Gist options
  • Save dgtized/7298153 to your computer and use it in GitHub Desktop.
Save dgtized/7298153 to your computer and use it in GitHub Desktop.
(defun github-browse ()
(interactive)
(let ((url (magit-get "remote" (magit-get-current-remote) "url")))
(save-match-data
(if (string-match "github.com:\\([^/]+\\)/\\([^\.]+\\).git" url)
(let ((owner (match-string 1 url))
(repo (match-string 2 url)))
(browse-url (format "https://github.com/%s/%s/blob/%s/%s#L%d"
owner repo
(magit-get-current-branch)
(magit-file-relative-name (buffer-file-name))
(line-number-at-pos))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment