I can see that I've got a terminal buffer open by running
:ls R which finds all buffers with a running terminal job, but I don't know how to capture just the buffer number.
The closest I can get is
echo bufnr("cmd.exe") because the buffer name has the command the terminal is using. This isn't crossplatform though.
bufnr("R") doesn't seem to search the flags the same was
:ls R does.