Skip to content

Instantly share code, notes, and snippets.

@koturn
Last active March 2, 2016 03:17
Show Gist options
  • Select an option

  • Save koturn/cd2482be912319427cc0 to your computer and use it in GitHub Desktop.

Select an option

Save koturn/cd2482be912319427cc0 to your computer and use it in GitHub Desktop.
job_start()の動作確認
function! s:get_sid_prefix() abort
return matchstr(expand('<sfile>'), '^function \zs<SNR>\d\+_\zeget_sid_prefix$')
endfunction
let s:sid_prefix = s:get_sid_prefix()
delfunction s:get_sid_prefix
function! s:callback(channel, msg) abort
echo "from the handler: " a:channel . ' : ' . a:msg
endfunction
let s:jobopt = {
\ 'callback': s:sid_prefix . 'callback'
\}
call job_start('bash -c "for i in {1..10}; do echo hello $i!; sleep 1; done"', s:jobopt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment