From 4918150bb463678b1a5eebfe0b8138d4cc7fb82a Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 6 Apr 2018 01:40:13 +0200 Subject: github-url: Copy the URL to the clipboard in addition to printing it Previously all we did was `echo` the generated URL to the command line. This was mainly for debugging purposes, but it strikes me that this would be nice to keep so that users can validate that the correct URL was generated. In addition to doing this, though, we need to provide an easy way to send that URL string into other programs like chat or an input field in a web browser. Copy the URL to the Mac OS X clipboard to make it easier to share. --- bundle/github-url/autoload/github_url.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bundle/github-url/autoload') diff --git a/bundle/github-url/autoload/github_url.vim b/bundle/github-url/autoload/github_url.vim index c83c6f6..e090681 100644 --- a/bundle/github-url/autoload/github_url.vim +++ b/bundle/github-url/autoload/github_url.vim @@ -30,6 +30,10 @@ function! s:FileURL(include_lines, start_line, end_line) return s:BaseRepoURL() . '/blob/' . current_sha . '/' . current_filename . lines endfunction +" Copy the GitHub URL to the clipboard and echo it to the command line. function! github_url#GitHubURL(include_lines, start_line, end_line) - return s:FileURL(a:include_lines, a:start_line, a:end_line) + let url = s:FileURL(a:include_lines, a:start_line, a:end_line) + + call system('pbcopy', url) + echo url endfunction -- cgit v1.2.3