From 7c47d3d3e03dd4ef75be1c6113a45ef5bd261ee3 Mon Sep 17 00:00:00 2001 From: Maxwell Pray Date: Fri, 28 Jul 2023 12:01:55 -0700 Subject: [PATCH 1/2] Add :ToGithubBlame to open "blame" route. --- plugin/to-github.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/to-github.vim b/plugin/to-github.vim index 7d5b6f1..24fbd90 100644 --- a/plugin/to-github.vim +++ b/plugin/to-github.vim @@ -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/"' @@ -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 @@ -100,4 +100,5 @@ function! ToGithub(count, line1, line2, ...) endif endfunction -command! -nargs=* -range ToGithub :call ToGithub(, , , ) +command! -nargs=* -range ToGithub :call ToGithub('blob', , , , ) +command! -nargs=* -range ToGithubBlame :call ToGithub('blame', , , , ) From efa1acbd71a3a66db84f2c606492592d1ee8c5a1 Mon Sep 17 00:00:00 2001 From: Maxwell Pray Date: Fri, 28 Jul 2023 12:07:25 -0700 Subject: [PATCH 2/2] Add :ToGithubBlame documentation to README.md. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 5073053..aea5d73 100644 --- a/README.md +++ b/README.md @@ -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 ```