I have two shell commands which I want to run. However I only want to run the second one if the first one was successful. For simplicity let the commands be ls and ls. I can call then once at a time manually, no problem.

:terminal ls
Home Documents ...
:terminal ls
Home Documents ...

But if I combine them, it breaks completely.

:terminal ls && ls
ls: cannot access '&&': No such file or directory
ls: cannot access 'ls': No such file or directory

From the buffer name it looks like it is calling :!ls && ls as it should. However !ls && ls gives the desired result for me, and :terminal ls && ls doesn't.

Can anybody explain this?

1 Answer 1


you need a shell to parse &&.

try :terminal bash -c "ls && ls"

without a shell ls will see all the arguments, including && and ls and will hence fail

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.