Created
February 27, 2019 12:37
-
-
Save rbtnn/92d74d51f522be95ed059c0a97688aed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
このままだと、すぐechoが消えちゃうので、echomsgとかに残すほうがいいかも