how do I determine the status of a process within a terminal tab?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how do I determine the status of a process within a terminal tab?

surge
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 an entry similar to:

 7 %aF "!echo "test" [finished]" line 1

Question: is there a vimscript 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. Namely,

before changes can be made to a terminal buffer, the 'modifiable' option must be set. This is only possible when the job has finished:

So, is examining the modifiable option the best way to determine if a shell process has finished? What if I wanted to examine the exis status?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/0f6bca70-40b8-46c3-953d-dd081fc6f782%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: how do I determine the status of a process within a terminal tab?

Yegappan Lakshmanan
Hi,

On Sat, Jan 4, 2020 at 3:12 AM surge <[hidden email]> wrote:

>
> 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 an entry similar to:
>
>  7 %aF "!echo "test" [finished]" line 1
>
> Question: is there a vimscript function that could return such extended information about a buffer?
>

Yes. You can use the term_getstatus() function to get the status of
the terminal.
You can use the getbufinfo(), term_getjob() and job_info() functions to get
additional details about the job running in a terminal window.

Example (assuming the buffer number for the terminal is 2):
     :echo term_getjob(2)->job_info()
     :echo term_getstatus(2)
     :echo term_getjob(2)->job_status()
     :echo getbufinfo(2)[0].name

- Yegappan

>
> :help terminal suggests that if modifiable option is off, the job had to have finished. Namely,
>
>> before changes can be made to a terminal buffer, the 'modifiable' option must be set. This is only possible when the job has finished:
>
>
> So, is examining the modifiable option the best way to determine if a shell process has finished? What if I wanted to examine the exis status?
>

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAAW7x7kcARmpjUmf69kasJCqt3-bH7axpjjBVJ_ZnHUvyj3kKA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: how do I determine the status of a process within a terminal tab?

surge
Thank you so much, Yegappan. That's exactly what I needed.

On Friday, January 3, 2020 at 7:57:37 PM UTC-6, Yegappan wrote:
Hi,

On Sat, Jan 4, 2020 at 3:12 AM surge <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Rsgf6iItCwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ger...@...> wrote:

>
> 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 an entry similar to:
>
>  7 %aF "!echo "test" [finished]" line 1
>
> Question: is there a vimscript function that could return such extended information about a buffer?
>

Yes. You can use the term_getstatus() function to get the status of
the terminal.
You can use the getbufinfo(), term_getjob() and job_info() functions to get
additional details about the job running in a terminal window.

Example (assuming the buffer number for the terminal is 2):
     :echo term_getjob(2)->job_info()
     :echo term_getstatus(2)
     :echo term_getjob(2)->job_status()
     :echo getbufinfo(2)[0].name

- Yegappan

>
> :help terminal suggests that if modifiable option is off, the job had to have finished. Namely,
>
>> before changes can be made to a terminal buffer, the 'modifiable' option must be set. This is only possible when the job has finished:
>
>
> So, is examining the modifiable option the best way to determine if a shell process has finished? What if I wanted to examine the exis status?
>

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4daf52d4-1bff-47a8-b38f-09e33bcff9a2%40googlegroups.com.