The :ls command in Vim output the current buffers in Vim. If one of the buffers is a terminal, there are some useful flags to examine there. For example, if the command was:
term echo "test"
:ls will contain this as one of the entries:
...
7 %aF "!echo "test" [finished]" line 1
...
Is there a vim function that could return such extended information about a buffer? :help terminal suggests that if modifiable option is off, the job had to have finished.
before changes can be made to a terminal buffer, the 'modifiable' option must be set. This is only possible when the job has finished:
To rephrase my question, how do I know the status of a shell process started with the term command?
Terminal process is always bound to a buffer, not a tab. In Vim there exists a function term_getstatus(); in Neovim it's jobwait().
Here is a generic function from my config:
function! term#running(buf)
return getbufvar(a:buf, '&buftype') !=# 'terminal' ? 0 :
\ has('terminal') ? term_getstatus(a:buf) =~# 'running' :
\ has('nvim') ? jobwait([getbufvar(a:buf, '&channel')], 0)[0] == -1 :
\ 0
endfunction
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With