hub browse相当の elisp関数(github限定)

個人的に hubコマンドを全然使いこなせていなくて、 hub browseしか
使っていなかったんですが、それだけだと大層だなぁということで、
elispで書いてみました。めんどくさいのと個人的に github以外不要
なので github限定にしています。

(defun magit-browse ()
  (interactive)
  (let ((url (with-temp-buffer
               (unless (zerop (call-process-shell-command "git remote -v" nil t))
                 (error "Failed: 'git remote -v'"))
               (goto-char (point-min))
               (when (re-search-forward "github\\.com[:/]\\(.+?\\)\\.git" nil t)
                 (format "https://github.com/%s" (match-string 1))))))
    (unless url
      (error "Can't find repository URL"))
    (browse-url url)))

(define-key magit-mode-map (kbd "C-c C-b") 'magit-browse)

これで git操作のために shellに移る必要がさらに減りそうですね。