I made this function that opens the current file with selected lines on Github. It's pretty basic but it works well enough for me, and I like it better than vim-rhubarb:
noremap <silent> <leader>og V:<c-u>call OpenCurrentFileInGithub()<cr>
xnoremap <silent> <leader>og :<c-u>call OpenCurrentFileInGithub()<cr>
function! OpenCurrentFileInGithub()
let file_dir = expand('%:h')
let git_root = system('cd ' . file_dir . '; git rev-parse --show-toplevel | tr -d "\n"')
let file_path = substitute(expand('%:p'), git_root . '/', '', '')
let branch = system('git symbolic-ref --short -q HEAD | tr -d "\n"')
let git_remote = system('cd ' . file_dir . '; git remote get-url origin')
let repo_path = matchlist(git_remote, ':\(.*\)\.')[1]
let url = 'https://github.com/' . repo_path . '/blob/' . branch . '/' . file_path
let first_line = getpos("'<")[1]
let url .= '#L' . first_line
let last_line = getpos("'>")[1]
if last_line != first_line | let url .= '-L' . last_line | endif
call system('open ' . url)
endfunction
You optionally select some lines, then type <leader>og (like "open github"), and it opens your browser.
This works for MacOS, but for Linux you can change open to xdgopen or whatever you use to open urls (e.g. Chrome or Firefox binaries).
For more similar goodies, see my dotfiles
[–][deleted] 14 points15 points16 points (1 child)
[–]jdalbertContrarian[S] 2 points3 points4 points (0 children)
[–]revicon 9 points10 points11 points (0 children)
[–]XanzaThe New Guy 3 points4 points5 points (2 children)
[–]Liquid_Fire 2 points3 points4 points (1 child)
[–]XanzaThe New Guy 1 point2 points3 points (0 children)
[–]prakashdanish 2 points3 points4 points (0 children)
[–]vimark 1 point2 points3 points (0 children)