0

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.

  • 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 $* – Luc Hermitte Mar 22 at 19:09
2

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

let &makeprg = 'sh -c "..."'
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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