0

Within vim, I'd like to run one of my .bashrc functions, ocr, in background. I've tried the following commands in .vimrc, which do not work:

set shell=bash\ --login  " to run bash aliases must use interactive shell
set shellcmdflag=-ic  " to run bash aliases must use interactive shell

This ex command does work, but it won't run it in background:

:!bash -c -i ocr &

instead returning the message:

bash: initialize_job_control: no job control in background: Bad file descriptor

and the job is running in fg so that I cannot return to vim.

user985675
  • 293
  • 3
  • 10
  • As mentioned in [this answer](https://stackoverflow.com/a/46939478/5411198), you need to export the shell function (`export -f ocr`). Then your command (`:!bash -c -i ocr &`) should work – builder-7000 Apr 06 '19 at 01:42
  • Actually not, it found the function and ran it, the problem was with no job control, which normally is enabled by default. – user985675 Apr 06 '19 at 19:18

1 Answers1

1

I've tried 3 "solutions" to this problem, 2 I listed in my original post, and one given by Sergio above. None of them worked for me, and I think its clear that what will work for any system depends very much on how that system is set up.

But I do know this: copying the function ocr into a script, ocr.sh and it runs just fine.

user985675
  • 293
  • 3
  • 10