summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/Interrupt.pm
blob: d25778538d357ba6b1ac916b1663f4270bf20a90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main;
use strict;
use warnings;
# ABSTRACT: allows using Ctrl+C to interrupt long-running lines

use mop;

=head1 SYNOPSIS

  ; .replyrc
  [Interrupt]

=head1 DESCRIPTION

This plugin allows you to use Ctrl+C to interrupt long running commands without
exiting the Reply shell entirely.

=cut

class Reply::Plugin::Interrupt extends Reply::Plugin {
    method compile ($next, @args) {
        local $SIG{INT} = sub { die "Interrupted" };
        $next->(@args);
    }

    method execute ($next, @args) {
        local $SIG{INT} = sub { die "Interrupted" };
        $next->(@args);
    }
}

1;