Created
March 13, 2018 15:54
-
-
Save dctucker/d20be758f3ace5a69242786f1b611588 to your computer and use it in GitHub Desktop.
Vimscript for opening the current file in GitHub for Mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! OpenGithub() | |
" let l:pwd = expand("%:p:h:t") | |
let l:branch = systemlist("git -C " . expand("%:p:h") . " symbolic-ref --quiet --short HEAD || git rev-parse --short HEAD")[0] | |
let l:root = systemlist("git -C " . expand("%:p:h") . " rev-parse --show-toplevel")[0] | |
let l:repo = fnamemodify(l:root, ":t") | |
let l:fn = substitute(expand("%"), escape(l:root, "/"), "", "g") | |
exec "!open https://github.com/github/" . l:repo . "/blob/" . l:branch . l:fn | |
endfunction | |
command! -nargs=0 GH call OpenGithub() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment