From 23d32b9dae77a88ea040983ab82f3ad7b6e57b9e Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 1 Feb 2016 08:51:17 +0100 Subject: [PATCH] allow yanking to X11 selection with new yank_x11 option --- bin/fcscs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/bin/fcscs b/bin/fcscs index 35e50e3..da614bc 100755 --- a/bin/fcscs +++ b/bin/fcscs @@ -899,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 { @@ -1042,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 @@ -1133,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>) @@ -1156,6 +1183,7 @@ my %setting = ( multiplexer => undef, ignorecase => 0, smartcase => 1, + yank_x11 => 0, paste_sleep => 100_000, screen_msgwait => 5, # global mappings -- 2.43.2