Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: monitor screen output
- X-seq: zsh-users 30104
- From: Sebastian Stark <sstark+zsh@xxxxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: monitor screen output
- Date: Mon, 11 Nov 2024 22:35:03 +0100
- Archived-at: <https://zsh.org/users/30104>
- In-reply-to: <4d7d4279-c30e-4c2d-9291-4ca985780673@eastlink.ca>
- List-id: <zsh-users.zsh.org>
- Mail-followup-to: Ray Andrews <rayandrews@xxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- References: <4d7d4279-c30e-4c2d-9291-4ca985780673@eastlink.ca>
Am Montag, den 11. November 2024 um 17:45 schrieb Ray Andrews:
All:
Can zsh monitor screen output in a backgroundy sort of way? Say I
have several programs that might at some time or other output some
message, can zsh keep an eye on the screen any time it is written to
and detect that message and act upon it?
If you want it to be done natively in zsh you could probably use the
zpty module (see zshmodules(1)):
Load the module:
$ zmodload zsh/zpty
Start top in the background. That would be your program to monitor.
It will get the handle 'top'. You may start several programs with
different handles:
$ zpty top top
Read from the pseudo terminal into "var" until pattern "*mutt*" was
found:
$ zpty -r top var "*neomutt*"
Now Start neomutt in another shell. Above command should return after a
couple seconds and $var should contain the top output including the
matched text.
Cancel the background process if you are done:
$ zpty -d top
Expect is probably the saner option to use.
Sebastian
Messages sorted by:
Reverse Date,
Date,
Thread,
Author