Skip to content

Instantly share code, notes, and snippets.

@rbtnn
Created February 27, 2019 12:37
Show Gist options
  • Save rbtnn/92d74d51f522be95ed059c0a97688aed to your computer and use it in GitHub Desktop.
Save rbtnn/92d74d51f522be95ed059c0a97688aed to your computer and use it in GitHub Desktop.
function s:handler_close_cb(channel) abort
let lines = []
while ch_status(a:channel, {'part': 'out'}) == 'buffered'
let lines += [ch_read(a:channel)]
endwhile
echo lines
endfunction
function s:main() abort
let src = expand('temp.vim')
call writefile(['echo "1"', 'echo "2"', 'echo "3"'], src)
let cmd = ['vim', '-X', '-N', '-u', 'NONE', '-i', 'NONE', '-V1', '-e', '-s', '-S', src, '+qall!']
let job = job_start(cmd, {
\ 'close_cb' : function('s:handler_close_cb'),
\ 'out_io' : 'pipe',
\ 'err_io' : 'out',
\ })
endfunction
call s:main()
" ['1', '2', '3
" 3
" 3']
@rbtnn
Copy link
Author

rbtnn commented Feb 27, 2019

このままだと、すぐechoが消えちゃうので、echomsgとかに残すほうがいいかも

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment