textual-terminal icon indicating copy to clipboard operation
textual-terminal copied to clipboard

A Message for when the command terminates

Open candidtim opened this issue 2 years ago • 4 comments

Is there a way to know (a Message?) when a command running in the terminal terminates? Or, put differently, when a terminal stops?

candidtim avatar Oct 04 '23 20:10 candidtim

Hi There

Thanks for your your question.

For the first question, I've to investigate it. Probably not, because it is not known for Textual, that a command inside the terminal widget has been run.

For the second question, possibly yes, if the command you've defined stopped. This should already trigger some Message from Textual itself. If it would be a command inside a widget running bash, probably not. That would be the same as above.

As soon as I've some spare time, I'll investigate it.

Mitosch

mitosch avatar Oct 04 '23 23:10 mitosch

I have looked into the source code and it seems that a call to the post_message can be added to the Terminal.stop() method. I have made a simple test by extending the class and it seems to work fine. Let me know if you accept Pull Requests, I can prepare one, maybe even with some niceties to parse the exit code to raise in the message.

candidtim avatar Oct 06 '23 18:10 candidtim

Yes, that would also be my idea for the second usecase. If that is, what you need, just make a pull request.

I'd be happy to merge it and release a new version.

mitosch avatar Oct 07 '23 00:10 mitosch

As it might be related to this: #8

juergenpabel avatar May 14 '24 14:05 juergenpabel