I would like to set the working directory for the process started with job_start().

The only way I know how to do this is to change Vim's current working directory before calling job_start(), and then change it back to what it was. That is a little bit of a hack, and I am afraid it could cause problems for some people. Does anyone know a better way?


1 Answer 1


In Build-Tool-Wrapper, I've used sh -c to actually run cd compdir && make args:

" the a:cmd is managed elsewhere in the plugin
" it may contain many things, usually things like 
"    `cd build/dir && make tgt -j 8 2>&1 | gSTLfilt.pl`
if lh#os#OnDOSWindows() && &shell =~ 'cmd'
  let cmd = &shell . ' /C '.a:cmd
  let cmd = ['sh', '-c', a:cmd]
let job = job_start(cmd,
      \ {
      \   'close_cb': ('CloseCB')
      \ , 'callback': ('CallbackCB')
      \ })


I haven't fully tested it yet on windows though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.