Skip to content
Open
Show file tree
Hide file tree
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: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ It's the same to replace the repo name:
:ToGithub username repo
```

You can also open the blame route:

```
:ToGithubBlame
```

You can also set a global option to copy the url in the clipboard instead of opening the browser

```
Expand Down
7 changes: 4 additions & 3 deletions plugin/to-github.vim
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function! s:copy_to_clipboard(url)
endif
endfunction

function! ToGithub(count, line1, line2, ...)
function! ToGithub(route, 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_username = 'sed -E "s/.*com[:\/](.*)\/.*/\\1/"'
Expand All @@ -84,7 +84,7 @@ function! ToGithub(count, line1, line2, ...)
let repo_root = s:run('git rev-parse --show-toplevel')
let file_path = expand('%:p')
let file_path = substitute(file_path, repo_root . '/', '', 'e')
let url = join([github_url, username, repo, 'blob', commit, file_path], '/')
let url = join([github_url, username, repo, a:route, commit, file_path], '/')

" Finally set the line numbers if necessary.
if a:count == -1
Expand All @@ -100,4 +100,5 @@ function! ToGithub(count, line1, line2, ...)
endif
endfunction

command! -nargs=* -range ToGithub :call ToGithub(<count>, <line1>, <line2>, <f-args>)
command! -nargs=* -range ToGithub :call ToGithub('blob', <count>, <line1>, <line2>, <f-args>)
command! -nargs=* -range ToGithubBlame :call ToGithub('blame', <count>, <line1>, <line2>, <f-args>)