aboutsummaryrefslogtreecommitdiffstats
path: root/bundle/github-url/autoload
diff options
context:
space:
mode:
authorTeddy Wing2018-04-06 01:40:13 +0200
committerTeddy Wing2018-04-06 01:40:13 +0200
commit4918150bb463678b1a5eebfe0b8138d4cc7fb82a (patch)
tree44ee0ccc2c20164b24ee50b9972d214bc49335c3 /bundle/github-url/autoload
parentbcb1336bd008efde95daae0599a656ca67c2d94f (diff)
downloaddotvim-4918150bb463678b1a5eebfe0b8138d4cc7fb82a.tar.bz2
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.
Diffstat (limited to 'bundle/github-url/autoload')
-rw-r--r--bundle/github-url/autoload/github_url.vim6
1 files changed, 5 insertions, 1 deletions
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