Fix watcher prompt detection
This commit is contained in:
@@ -23,7 +23,6 @@ use IO::Select;
|
||||
use POSIX qw(strftime mkfifo);
|
||||
|
||||
my $SCRIPT = '/Users/jetpac/bin/watcher.pl';
|
||||
my $LINES = 20;
|
||||
my $COOLDOWN = $ENV{WATCHER_COOLDOWN} || 60;
|
||||
my $LOG_FILE = $ENV{WATCHER_LOG} || '';
|
||||
my @PROMPTS = (
|
||||
@@ -219,7 +218,7 @@ sub maybe_confirm {
|
||||
my ($sock, $pane, $last_confirm_ref, $last_signature_ref, $source) = @_;
|
||||
my $now = time;
|
||||
|
||||
my ($ok, $screen) = rendered_last_lines($sock, $pane, $LINES);
|
||||
my ($ok, $screen) = rendered_visible_pane($sock, $pane);
|
||||
exit 0 if !$ok;
|
||||
|
||||
return if !has_any_prompt($screen);
|
||||
@@ -240,21 +239,18 @@ sub maybe_confirm {
|
||||
}
|
||||
}
|
||||
|
||||
sub rendered_last_lines {
|
||||
my ($sock, $pane, $lines) = @_;
|
||||
sub rendered_visible_pane {
|
||||
my ($sock, $pane) = @_;
|
||||
my @cmd = (
|
||||
'tmux', '-S', $sock,
|
||||
'capture-pane', '-p',
|
||||
'-t', $pane,
|
||||
'-S', '-' . ($lines * 3),
|
||||
);
|
||||
|
||||
my ($ok, $out) = run_capture(@cmd);
|
||||
return (0, '') if !$ok;
|
||||
|
||||
my @lines = split /\n/, clean_text($out);
|
||||
@lines = @lines > $lines ? @lines[-$lines .. -1] : @lines;
|
||||
return (1, join("\n", @lines));
|
||||
return (1, clean_text($out));
|
||||
}
|
||||
|
||||
sub start_pipe {
|
||||
|
||||
Reference in New Issue
Block a user