Created
March 18, 2019 07:49
-
-
Save xtetsuji/75edada3a55cb29ce2acecdd171e1826 to your computer and use it in GitHub Desktop.
inurl - open URLs in the default browser, URLs are choiced from STDIN by peco
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# 2019/03/14 | |
# inurl - 標準入力を peco に渡して、URL がある行を選択するとその URL をブラウザで開く | |
use strict; | |
use warnings; | |
use IPC::Open2; | |
my (@url, $child_out, $child_in); | |
open2 $child_out, $child_in, 'peco'; | |
while (<>) { | |
print {$child_in} $_; | |
} | |
close $child_in; | |
while (<$child_out>) { | |
chomp; | |
if ( m{https?://\S+}p ) { | |
system 'open', ${^MATCH}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment