Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions plugin/to-github.vim
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ function! s:copy_to_clipboard(url)
endfunction

function! ToGithub(count, line1, line2, ...)
let github_url = 'https://github.com'
let get_remote = 'git remote -v | grep -E "github\.com.*\(fetch\)" | head -n 1'
let get_remote = 'git remote -v | grep -E "^origin +.*\(fetch\)$" | head -n 1' " Uses literal tab stop in regex.
let get_host = 'sed "s,^origin\t\+\([^@]\+@\|https://\)\([^/:]\+\).*,\2,"'
let get_username = 'sed -E "s/.*com[:\/](.*)\/.*/\\1/"'
let get_repo = 'sed -E "s/.*com[:\/].*\/(.*).*/\\1/" | cut -d " " -f 1'
let optional_ext = 'sed -E "s/\.git//"'

let github_url = 'https://' . s:run(get_remote, get_host)

" Get the username and repo.
if len(a:000) == 0
let username = s:run(get_remote, get_username)
Expand Down