Last active
November 25, 2021 09:14
-
-
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.
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! 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually it doesn't work for me in the first place... I get some error from bash. Anyway for multiline you could try something like:
I'm not a "vim-command-maker-expert" so take this until someone else comes by with a better solution 👍