Last active
November 4, 2016 18:23
-
-
Save nickav/dd7ba45786e113fcffec97c2d520be5d to your computer and use it in GitHub Desktop.
Get a Github link to the current cursor position
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! GithubLink() | |
let remote = system("git remote -v | sed -n '1 p' | awk '{print $2}'") | |
let remote = substitute(remote, ".git\n", "", "") | |
let line = line(".") | |
let fname = expand("%@") | |
let linestr = "#L" . line | |
if line == 1 | |
let linestr = '' | |
endif | |
echo remote . "/blob/master/" . fname . linestr | |
endfunction | |
command! GithubLink :call GithubLink() | |
command! Glink :call GithubLink() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment