Skip to content

Instantly share code, notes, and snippets.

@callahanrts
Last active November 25, 2021 09:14
Show Gist options
  • Save callahanrts/9274ad952b3e79cccc44 to your computer and use it in GitHub Desktop.
Save callahanrts/9274ad952b3e79cccc44 to your computer and use it in GitHub Desktop.
Vim command to open a browser tab at the selected line of any git project.
function! ShowOnGithub()
let u = system("echo ${${${$(git --git-dir=.git config --get remote.origin.url)#[email protected]:}%.git}#https://github.com/} | xargs echo -n")
silent exec "!open "."https://github.com/".u."/blob/master/".@%.'\#L'.line(".")
endfunction
command! -nargs=0 ShowOnGithub call ShowOnGithub()
nnoremap <Leader>gh :ShowOnGithub<CR>
@dstokes
Copy link

dstokes commented Feb 28, 2015

https://github.com/tpope/vim-fugitive does this pretty well via :Gbrowse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment