view release on metacpan or search on metacpan
0.003 2026-04-09 Released-By: PERLANCAR; Urgency: medium
- Observe tag: no_copy_title.
0.002 2026-04-08 Released-By: PERLANCAR; Urgency: medium
- [utility cs-select] Tweak added clipboard content.
0.001 2026-04-08 Released-By: PERLANCAR
- First release.
* fzf2clip
* fzf2clip-loop
FUNCTIONS
cs_select
Usage:
cs_select(%args) -> [$status_code, $reason, $payload, \%result_meta]
Select entries from template to clipboard.
This is basically similar to:
% fzf --bind 'enter:execute(clipadd {})' < template.txt
except that it does some pre-processing to let each template entry be a
multiple-line text, and later do post-processing so the original entry
is added to the clipboard.
Template format
Template is an Org file with a particular format, where each entry is
put under a level-2 heading. The level-1 heading can be used for
grouping/categorizing. For example:
* Product > P1
** Does P1 need to be replaced every 5 years? :replacement:clipadd_1:
Yes, ideally every 3-5 years.
[id=4][title=Entry 2]...[category=Product > P2]
[id=5][title=Entry 3]...[category=General > Support]
[id=6][title=Entry 4]...[category=General > Support]
after selection, another script (cs-select-helper) will turn back the
single-line entry into the original.
Tags
Some Org tags are used to customize how the entry is displayed or copied
to clipboard.
no_copy_title. Do not copy the title to clipboard.
This function is not exported.
Arguments ('*' denotes required arguments):
* template => *str*
(No description)
* wrap => *posint*
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
fzf2clip
Usage:
fzf2clip(%args) -> [$status_code, $reason, $payload, \%result_meta]
Select using fzf, then add selection to clipboard.
This is basically a shortcut for:
% fzf < input.txt | clipadd
where clipadd is a utility from App::ClipboardUtils.
This function is not exported.
Arguments ('*' denotes required arguments):
* input => *str*
(No description)
* tee => *bool*
In addition to adding to clipboard, also print to STDOUT.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
lib/App/FzfUtils.pm view on Meta::CPAN
our %SPEC;
$SPEC{':package'} = {
v => 1.1,
summary => 'Utilities related to fzf',
};
$SPEC{fzf2clip} = {
v => 1.1,
summary => "Select using fzf, then add selection to clipboard",
description => <<'MARKDOWN',
This is basically a shortcut for:
% fzf < input.txt | clipadd
where <prog:clipadd> is a utility from <pm:App::ClipboardUtils>.
MARKDOWN
args => {
input => {
schema => 'str*',
cmdline_src => 'stdin_or_files',
pos => 0,
},
tee => {
summary => 'In addition to adding to clipboard, also print to STDOUT',
schema => 'bool*',
cmdline_aliases => {t=>{}},
},
},
deps => {
all => [
{prog => 'fzf'},
#{prog => 'clipadd'},
],
},
lib/App/FzfUtils.pm view on Meta::CPAN
my $result;
{
local $/;
$result = <$out>;
chomp($result) if defined $result;
}
close $out;
waitpid($pid, 0);
ADD_CLIPBOARD: {
my $res = Clipboard::Any::add_clipboard_content(content => $result);
return [500, "Can't add to clipboard: $res->[0] - $res->[1]"]
unless $res->[0] == 200;
}
[200, "OK", $args{tee} ? $result : ""];
}
$SPEC{fzf2clip_loop} = {
v => 1.1,
summary => "Like fzf2clip, but loop/repeat",
description => <<'MARKDOWN',
lib/App/FzfUtils.pm view on Meta::CPAN
}
close $in;
close $out;
waitpid($pid, 0);
[200, "OK"];
}
$SPEC{cs_select} = {
v => 1.1,
summary => "Select entries from template to clipboard",
description => <<'MARKDOWN',
This is basically similar to:
% fzf --bind 'enter:execute(clipadd {})' < template.txt
except that it does some pre-processing to let each template entry be a
multiple-line text, and later do post-processing so the original entry is added
to the clipboard.
**Template format**
Template is an Org file with a particular format, where each entry is put under
a level-2 heading. The level-1 heading can be used for grouping/categorizing.
For example:
* Product > P1
** Does P1 need to be replaced every 5 years? :replacement:clipadd_1:
Yes, ideally every 3-5 years.
lib/App/FzfUtils.pm view on Meta::CPAN
[id=4][title=Entry 2]...[category=Product > P2]
[id=5][title=Entry 3]...[category=General > Support]
[id=6][title=Entry 4]...[category=General > Support]
after selection, another script (<prog:cs-select-helper>) will turn back the
single-line entry into the original.
**Tags**
Some Org tags are used to customize how the entry is displayed or copied to
clipboard.
**no_copy_title**. Do not copy the title to clipboard.
MARKDOWN
args => {
template => {
schema => 'str*',
cmdline_src => 'stdin_or_files',
pos => 0,
},
wrap => {
schema => 'posint*',
lib/App/FzfUtils.pm view on Meta::CPAN
=head1 FUNCTIONS
=head2 cs_select
Usage:
cs_select(%args) -> [$status_code, $reason, $payload, \%result_meta]
Select entries from template to clipboard.
This is basically similar to:
% fzf --bind 'enter:execute(clipadd {})' < template.txt
except that it does some pre-processing to let each template entry be a
multiple-line text, and later do post-processing so the original entry is added
to the clipboard.
B<Template format>
Template is an Org file with a particular format, where each entry is put under
a level-2 heading. The level-1 heading can be used for grouping/categorizing.
For example:
* Product > P1
** Does P1 need to be replaced every 5 years? :replacement:clipadd_1:
Yes, ideally every 3-5 years.
lib/App/FzfUtils.pm view on Meta::CPAN
[id=4][title=Entry 2]...[category=Product > P2]
[id=5][title=Entry 3]...[category=General > Support]
[id=6][title=Entry 4]...[category=General > Support]
after selection, another script (L<cs-select-helper>) will turn back the
single-line entry into the original.
B<Tags>
Some Org tags are used to customize how the entry is displayed or copied to
clipboard.
B<no_copy_title>. Do not copy the title to clipboard.
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<template> => I<str>
(No description)
lib/App/FzfUtils.pm view on Meta::CPAN
Return value: (any)
=head2 fzf2clip
Usage:
fzf2clip(%args) -> [$status_code, $reason, $payload, \%result_meta]
Select using fzf, then add selection to clipboard.
This is basically a shortcut for:
% fzf < input.txt | clipadd
where L<clipadd> is a utility from L<App::ClipboardUtils>.
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<input> => I<str>
(No description)
=item * B<tee> => I<bool>
In addition to adding to clipboard, also print to STDOUT.
=back
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or something like "OK" if status is
200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth
script/cs-select view on Meta::CPAN
my $cmdline = Perinci::CmdLine::Any->new(
url => "/App/FzfUtils/cs_select",
program_name => "cs-select",
log => 1,
read_config => 0,
read_env => 0,
);
$cmdline->run;
# ABSTRACT: Select entries from template to clipboard
# PODNAME: cs-select
__END__
=pod
=encoding UTF-8
=head1 NAME
cs-select - Select entries from template to clipboard
=head1 VERSION
This document describes version 0.003 of cs-select (from Perl distribution App-FzfUtils), released on 2026-04-09.
=head1 SYNOPSIS
B<cs-select> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)
B<cs-select> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)
script/cs-select view on Meta::CPAN
B<cs-select> [B<L<--debug|/"--debug">>|B<L<--log-level|/"--log-level=s">>=I<level>|B<L<--quiet|/"--quiet">>|B<L<--trace|/"--trace">>|B<L<--verbose|/"--verbose">>] [B<L<--format|/"--format=s">>=I<name>|B<L<--json|/"--json">>] [B<L<--(no)naked-res|/"--...
=head1 DESCRIPTION
This is basically similar to:
% fzf --bind 'enter:execute(clipadd {})' < template.txt
except that it does some pre-processing to let each template entry be a
multiple-line text, and later do post-processing so the original entry is added
to the clipboard.
B<Template format>
Template is an Org file with a particular format, where each entry is put under
a level-2 heading. The level-1 heading can be used for grouping/categorizing.
For example:
* Product > P1
** Does P1 need to be replaced every 5 years? :replacement:clipadd_1:
Yes, ideally every 3-5 years.
script/cs-select view on Meta::CPAN
[id=4][title=Entry 2]...[category=Product > P2]
[id=5][title=Entry 3]...[category=General > Support]
[id=6][title=Entry 4]...[category=General > Support]
after selection, another script (L<cs-select-helper>) will turn back the
single-line entry into the original.
B<Tags>
Some Org tags are used to customize how the entry is displayed or copied to
clipboard.
B<no_copy_title>. Do not copy the title to clipboard.
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
=over
=item B<--template>=I<s>
script/cs-select-helper view on Meta::CPAN
my $content = <$fh>;
require JSON::PP;
$data = JSON::PP::decode_json($content);
close $fh;
}
ref($data) eq 'HASH' or die "$prog: Data in JSON file '$jsonfile' is not a hash\n";
$data->{$id} or die "$prog: ID '$id' not known in JSON file '$jsonfile'\n";
require Clipboard::Any;
my $res = Clipboard::Any::add_clipboard_content(content => $data->{$id});
$res->[0] == 200 or die "$prog: Cannot add to clipboard: $res->[0] - $res->[1]\n";
1;
# ABSTRACT: cs-select helper script
# PODNAME: cs-select-helper
__END__
=pod
script/fzf2clip view on Meta::CPAN
my $cmdline = Perinci::CmdLine::Any->new(
url => "/App/FzfUtils/fzf2clip",
program_name => "fzf2clip",
log => 1,
read_config => 0,
read_env => 0,
);
$cmdline->run;
# ABSTRACT: Select using fzf, then add selection to clipboard
# PODNAME: fzf2clip
__END__
=pod
=encoding UTF-8
=head1 NAME
fzf2clip - Select using fzf, then add selection to clipboard
=head1 VERSION
This document describes version 0.003 of fzf2clip (from Perl distribution App-FzfUtils), released on 2026-04-09.
=head1 SYNOPSIS
B<fzf2clip> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)
B<fzf2clip> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)
script/fzf2clip view on Meta::CPAN
=item B<--input>=I<s>
(No description)
Can also be specified as the 1st command-line argument.
=item B<--tee>, B<-t>
In addition to adding to clipboard, also print to STDOUT.
=back
=head2 Logging options
=over
=item B<--debug>
Shortcut for --log-level=debug.