Skip to content

Instantly share code, notes, and snippets.

@RobertDober
Created June 21, 2017 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertDober/8e1ee67024cb23fc2ac3a3026d49f58d to your computer and use it in GitHub Desktop.
Save RobertDober/8e1ee67024cb23fc2ac3a3026d49f58d to your computer and use it in GitHub Desktop.
function! lab42#buffer#gist(line1, line2, ...)
let l:lines = getline(a:line1, a:line2)
if a:0
let l:basename = a:1
else
let l:basename = expand("%:t")
endif
let l:gistfile = '/tmp/' . l:basename
call writefile(l:lines, l:gistfile)
let l:result = system('gist ' . l:gistfile)
call system('open ' . l:result)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment