X-Git-Url: https://ruderich.org/simon/gitweb/?p=fcscs%2Ffcscs.git;a=blobdiff_plain;f=bin%2Ffcscs;h=27c133a35a71388f2c66f0c13fbfb976d3190e98;hp=c44b8eaeb623c53846ee2b8f8c22931acc56e17f;hb=ea3bc49201432df82468c251e8fd1f259b579a64;hpb=3789524cb5c0c5b5ba709308eae071d0d79b3598 diff --git a/bin/fcscs b/bin/fcscs index c44b8ea..27c133a 100755 --- a/bin/fcscs +++ b/bin/fcscs @@ -370,7 +370,7 @@ package Screen { foreach (@args) { $_ = $self->encode($_); } - say $fh "$module: @args"; + say $fh "$module: @args" or CORE::die $!; return; } @@ -502,9 +502,11 @@ sub run_in_background { # Necessary for GNU screen or it'll keep the window open until an # external command has run. - close STDIN or die $!; - close STDOUT or die $!; - close STDERR or die $!; + require File::Spec; + my $devnull = File::Spec->devnull(); + open STDIN, '<', $devnull or die $!; + open STDOUT, '>', $devnull or die $!; + open STDERR, '>', $devnull or die $!; # Double-fork to prevent zombies. my $pid = fork; @@ -876,7 +878,7 @@ sub handler_yank { # Use a temporary file to prevent leaking the yanked data to other users # with the command line, e.g. ps aux or top. my ($fh, $tmp) = File::Temp::tempfile(); # dies on its own - print $fh $screen->encode($match->{value}); + print $fh $screen->encode($match->{value}) or die $!; close $fh or die $!; if ($config->{setting}{multiplexer} eq 'screen') { @@ -897,6 +899,28 @@ sub handler_yank { } unlink $tmp or die $!; + + if ($config->{setting}{yank_x11}) { + $screen->debug('handler_yank', 'setting X11 selection'); + + my @xsel_cmd = qw( xsel --input --primary ); + my @xclip_cmd = qw( xclip -in -selection primary ); + + my $fh; + { + # We don't care if a program doesn't exist. + no warnings; + + if (not open $fh, '|-', @xsel_cmd) { + if (not open $fh, '|-', @xclip_cmd) { + die "install xsel or xlip to yank to X11 selection\n"; + } + } + } + print $fh $match->{value} or die $!; + close $fh or die $!; + } + return; } sub handler_paste { @@ -1040,6 +1064,9 @@ The following simple mappings are available by default: =back +Note that yanking only uses the GNU screen or Tmux paste buffer by default. To +also copy to X11 selection, enable the B option. + The following additional mappings are available by default: =over @@ -1131,6 +1158,8 @@ Defaults in parentheses. =item B ignore case unless one uppercase character is searched (C<1>) +=item B copy selection also to X11 primary selection when yanking (C<0>) + =item B sleep x us before running paste command (C<100_000>) =item B GNU Screen's msgwait variable, used when yanking (C<5>) @@ -1154,6 +1183,7 @@ my %setting = ( multiplexer => undef, ignorecase => 0, smartcase => 1, + yank_x11 => 0, paste_sleep => 100_000, screen_msgwait => 5, # global mappings