use Irssi::UI;
use Irssi::TextUI;
use MIME::Base64;
+use File::Glob qw/:bsd_glob/;
-$VERSION = '0.03';
+$VERSION = '0.04';
%IRSSI = (
authors => 'vague,bw1',
contact => 'bw1@aol.at',
description => 'copy a line in a paste buffer',
license => 'Public Domain',
url => 'https://scripts.irssi.org/',
- changed => '2019-06-25',
- modules => 'MIME::Base64',
+ changed => '2019-11-21',
+ modules => 'MIME::Base64 File::Glob',
commands=> 'copy',
);
xsel
screen
print
+ file
+ $IRSSI{name}_file
+ $IRSSI{name}_file_mode
+ $IRSSI{name}_file_eol
%9See also%9
https://www.freecodecamp.org/news/tmux-in-practice-integration-with-system-clipboard-bcd72c62ff7b/
http://anti.teamidiot.de/static/nei/*/Code/urxvt/
# line buffer
my ($copy_selection, $copy_method);
+my ($copy_file, $copy_file_mode, $copy_file_eol);
sub cmd_copy {
paste_screen($str, $copy_selection);
} elsif ( $copy_method eq 'print' ) {
paste_print($str, $copy_selection);
+ } elsif ( $copy_method eq 'file' ) {
+ paste_file($str, $copy_selection);
}
}
+sub paste_file {
+ my ($str, $par)= @_;
+ open my $fa, $copy_file_mode, $copy_file;
+ print $fa $str, $copy_file_eol;
+ close $fa;
+}
+
sub paste_print {
my ($str, $par)= @_;
Irssi::print($str, MSGLEVEL_CLIENTCRAP);
Irssi::settings_set_str($IRSSI{name}.'_selection', $cs);
}
my $cm= Irssi::settings_get_str($IRSSI{name}.'_method');
- my %md=(xterm=>1, xclip=>1, xsel=>1, screen=>1, print=>1 );
+ my %md=(xterm=>1, xclip=>1, xsel=>1, screen=>1, print=>1, file=>1 );
if (exists $md{$cm} ) {
$copy_method= $cm;
} else {
$cm= $copy_method;
Irssi::settings_set_str($IRSSI{name}.'_method', $cm);
}
+ my $fn= Irssi::settings_get_str($IRSSI{name}.'_file');
+ $copy_file= bsd_glob($fn);
+ my $fm= Irssi::settings_get_str($IRSSI{name}.'_file_mode');
+ $copy_file_mode= $fm;
+ my $fe= Irssi::settings_get_str($IRSSI{name}.'_file_eol');
+ $fe =~ s/\\n/\n/g;
+ $fe =~ s/\\t/\t/g;
+ $copy_file_eol= $fe;
}
Irssi::signal_add('setup changed', \&sig_setup_changed);
Irssi::settings_add_str($IRSSI{name} ,$IRSSI{name}.'_selection', '');
Irssi::settings_add_str($IRSSI{name} ,$IRSSI{name}.'_method', 'xterm');
+Irssi::settings_add_str($IRSSI{name} ,$IRSSI{name}.'_file', '');
+Irssi::settings_add_str($IRSSI{name} ,$IRSSI{name}.'_file_mode', '>');
+Irssi::settings_add_str($IRSSI{name} ,$IRSSI{name}.'_file_eol', '\n');
Irssi::command_bind($IRSSI{name}, \&cmd_copy);
Irssi::command_bind('help', \&cmd_help);