Permalink
Browse files

pbcopyを追加

  • Loading branch information...
1 parent 98b7cff commit 743101d7a5b85cac1eb7c9d36c7ab591ee53115e @tmsanrinsha committed Jan 4, 2013
Showing with 36 additions and 0 deletions.
  1. +36 −0 bin/pbcopy
View
@@ -0,0 +1,36 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use MIME::Base64;
+use Encode;
+use constant TMUXLEN => 250;
+use constant SCREENLEN => 510;
+binmode STDIN, ':encoding(utf8)';
+
+my $input = do {
+ local $/;
+ <STDIN>;
+};
+$input =~ s/ \n+ \z//xsm;
+$input =~ s/\n/\r\n/g;
+$input = encode_base64( encode('cp932', $input), q{} );
+
+# if( $ENV{TMUX}) {
+if($ENV{TERM} eq 'xterm-256color' ) {
+ print "\ePtmux;\e\e]52;;\e\\";
+ # 分割して送信
+ for(my $i = 0, my $len = length($input); TMUXLEN * $i < $len; $i++) {
+ my $str = substr($input, TMUXLEN * $i, TMUXLEN);
+ print "\ePtmux;$str\e\\";
+ }
+ print "\ePtmux;\e\e\\\\\e\\";
+# } elsif( $ENV{TERM} eq 'xterm-256color' ) {
+# print "\eP\e]52;;\e\\";
+# for(my $i = 0, my $len = length($input); SCREENLEN * $i < $len; $i++) {
+# my $str = substr($input, SCREENLEN * $i, SCREENLEN);
+# print "\eP$str\e\\";
+# }
+# print "\eP\x07\e\\";
+} else {
+ print "\e]52;;$input\e\\";
+}

0 comments on commit 743101d

Please sign in to comment.