1

Is it possible to silently run an external command, but show the output on the prompt only if there was any?

1
  • You can try let output = system(...) and then check if output is not empty and echo output
    – Maxim Kim
    Commented Dec 4, 2019 at 15:45

1 Answer 1

0

If by external command you do mean shell commands then you can try using system function :h system():

No output (on Windows)

let s:output = system("title")
if s:output != ''
    echom s:output
endif

Output

let s:output = system("date")
if s:output != ''
    echom s:output
endif

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.