1

I want to make something like this:

let &makerpg = '[ -f Makefile] && make || cd build && [ -f Makefile ] && make || cd ../build && [ -f Makefile ] && make || echo "Error"'

My goal is to make make to work in any place if it is within this kind of tree:

/Proyect-root
 /src
 /build
 /include

Edit: Actually I already have a pretty similar map:

nnoremap <silent><F4> :wa<bar>cd ../build<bar>make<cr><cr>:cd -<cr>:echo 'Done'<cr>

It's quite simple but obviously it doesn't work if I am in the root of my project.

1
  • 1
    In my plugins, I've taken another approach: I auto-detect, or register, where the actual build directory is (I can change it to switch between compilation modes), and always set makeprg to cd {thebuilddir} && make $* Commented Mar 22, 2020 at 19:09

1 Answer 1

2

If you need to do sh/bash commands, you should run it via sh -c

let &makeprg = 'sh -c "..."'

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.