App-GrepUtils
view release on metacpan or search on metacpan
script/grep-nonblank-clipboard view on Meta::CPAN
#!perl
use 5.010001;
use strict;
use warnings;
#use Log::ger;
use Clipboard::Any ();
use Getopt::Long;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2026-07-16'; # DATE
our $DIST = 'App-GrepUtils'; # DIST
our $VERSION = '0.007'; # VERSION
our %Opts = (
clipboard_manager => undef,
tee => 0,
);
sub parse_cmdline {
Getopt::Long::Configure('auto_abbrev', 'pass_through');
my $res = GetOptions(
'version|V' => sub {
no warnings 'once';
say "grep-terms version ", ($main::VERSION // 'dev');
exit 0;
},
'help' => sub {
print <<USAGE;
Usage:
grep-nonblank-clipboard [OPTIONS | FILES]...
grep-nonblank-clipboard --help
grep-nonblank-clipboard --version|-V
Options:
--clipboard-manager=s
--tee
Examples:
% grep-nonblank-clipboard
For more details, see the manpage/documentation.
USAGE
exit 0;
},
'clipboard-manager=s' => \$Opts{clipboard_manager},
'tee' => \$Opts{tee},
);
exit 99 if !$res;
}
sub run {
my $res;
$res = Clipboard::Any::get_clipboard_content(clipboard_manager=>$Opts{clipboard_manager});
die "Can't get clipboard content: $res->[0] - $res->[1]\n"
unless $res->[0] == 200;
my $text = $res->[2];
my @res;
for (split /^/m, $text) {
push @res, $_ if /\S/;
}
$res = Clipboard::Any::add_clipboard_content(clipboard_manager=>$Opts{clipboard_manager}, content=>join("", @res));
die "Can't add clipboard content: $res->[0] - $res->[1]\n"
unless $res->[0] == 200;
print @res if $Opts{tee};
}
# MAIN
parse_cmdline();
run();
1;
# ABSTRACT: Remove blank lines in clipboard content
# PODNAME: grep-nonblank-clipboard
__END__
=pod
=encoding UTF-8
( run in 0.512 second using v1.01-cache-2.11-cpan-9169edd2b0e )