* monitor screen output
@ 2024-11-11 16:44 Ray Andrews
2024-11-11 16:49 ` Bart Schaefer
2024-11-11 21:35 ` Sebastian Stark
0 siblings, 2 replies; 9+ messages in thread
From: Ray Andrews @ 2024-11-11 16:44 UTC (permalink / raw)
To: Zsh Users
[-- Attachment #1: Type: text/plain, Size: 253 bytes --]
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?
[-- Attachment #2: Type: text/html, Size: 479 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: monitor screen output
2024-11-11 16:44 monitor screen output Ray Andrews
@ 2024-11-11 16:49 ` Bart Schaefer
2024-11-11 17:18 ` Ray Andrews
2024-11-11 17:24 ` Josef Sachs
2024-11-11 21:35 ` Sebastian Stark
1 sibling, 2 replies; 9+ messages in thread
From: Bart Schaefer @ 2024-11-11 16:49 UTC (permalink / raw)
To: Ray Andrews; +Cc: Zsh Users
On Mon, Nov 11, 2024 at 8:45 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> Can zsh monitor screen output in a backgroundy sort of way?
No. That would need to be a function of the terminal itself (or
terminal emulator, which might have a better chance).
Otherwise if you direct those messages to a file, there are various
ways (still not directly part of zsh) to monitor file changes.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: monitor screen output
2024-11-11 16:49 ` Bart Schaefer
@ 2024-11-11 17:18 ` Ray Andrews
2024-11-11 18:13 ` Eric Pruitt
2024-11-11 17:24 ` Josef Sachs
1 sibling, 1 reply; 9+ messages in thread
From: Ray Andrews @ 2024-11-11 17:18 UTC (permalink / raw)
To: zsh-users
On 2024-11-11 08:49, Bart Schaefer wrote:
> On Mon, Nov 11, 2024 at 8:45 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>> Can zsh monitor screen output in a backgroundy sort of way?
> No. That would need to be a function of the terminal itself (or
> terminal emulator, which might have a better chance).
>
> Otherwise if you direct those messages to a file, there are various
> ways (still not directly part of zsh) to monitor file changes.
I think the terminal emulator I use does keep a file. I'll look into
that. It would be cool if every screen write tripped a flag somewhere
tho, then it would be easy. Tx.
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: monitor screen output
2024-11-11 17:18 ` Ray Andrews
@ 2024-11-11 18:13 ` Eric Pruitt
2024-11-11 21:45 ` Ray Andrews
0 siblings, 1 reply; 9+ messages in thread
From: Eric Pruitt @ 2024-11-11 18:13 UTC (permalink / raw)
To: Ray Andrews; +Cc: zsh-users
[-- Attachment #1: Type: text/plain, Size: 641 bytes --]
On Mon, Nov 11, 2024 at 09:18:31AM -0800, Ray Andrews wrote:
> I think the terminal emulator I use does keep a file. I'll look into that.
> It would be cool if every screen write tripped a flag somewhere tho, then it
> would be easy. Tx.
Depending on what exactly you want to do, you could probably achieve
this using tmux and some combination of its hooks, pane flags and/or
pipe-pane. I recommend searching for "monitor-", "-hook" and "pipe-pane"
in tmux(1). Whether this would be better than Expect would depend on the
task at hand. If you don't already use tmux and aren't interested in
using it, Expect is probably better.
Eric
[-- Attachment #2: Type: text/html, Size: 914 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: monitor screen output
2024-11-11 16:49 ` Bart Schaefer
2024-11-11 17:18 ` Ray Andrews
@ 2024-11-11 17:24 ` Josef Sachs
2024-11-11 18:01 ` Ray Andrews
1 sibling, 1 reply; 9+ messages in thread
From: Josef Sachs @ 2024-11-11 17:24 UTC (permalink / raw)
To: Ray Andrews; +Cc: Zsh Users
>>>>> On Mon, 11 Nov 2024 08:49:37 -0800, Bart Schaefer said:
> On Mon, Nov 11, 2024 at 8:45 AM Ray Andrews <rayandrews@eastlink.ca>
> wrote:
>>
>> Can zsh monitor screen output in a backgroundy sort of way?
> No. That would need to be a function of the terminal itself (or
> terminal emulator, which might have a better chance).
> Otherwise if you direct those messages to a file, there are various
> ways (still not directly part of zsh) to monitor file changes.
Perhaps consider expect. The Wikipedia page also lists some alternatives.
https://en.wikipedia.org/wiki/Expect
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: monitor screen output
2024-11-11 16:44 monitor screen output Ray Andrews
2024-11-11 16:49 ` Bart Schaefer
@ 2024-11-11 21:35 ` Sebastian Stark
2024-11-11 21:48 ` Ray Andrews
1 sibling, 1 reply; 9+ messages in thread
From: Sebastian Stark @ 2024-11-11 21:35 UTC (permalink / raw)
To: Ray Andrews; +Cc: Zsh Users
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-11-11 21:49 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-11 16:44 monitor screen output Ray Andrews
2024-11-11 16:49 ` Bart Schaefer
2024-11-11 17:18 ` Ray Andrews
2024-11-11 18:13 ` Eric Pruitt
2024-11-11 21:45 ` Ray Andrews
2024-11-11 17:24 ` Josef Sachs
2024-11-11 18:01 ` Ray Andrews
2024-11-11 21:35 ` Sebastian Stark
2024-11-11 21:48 ` Ray Andrews
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).