Created
July 11, 2023 00:22
-
-
Save hboon/bea96acb8dd31cf0f45cfd0ae444774f to your computer and use it in GitHub Desktop.
Opens URLs embedded in STDIN (so it's useful in vim by selecting text and running it)
This file contains 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 ruby | |
#Opens URLs embedded in STDIN (so it's useful in vim by selecting text and running it) | |
require 'uri' | |
input = $stdin.read.split("\n") | |
urls = input.map do |line| | |
URI.extract(line, ['http', 'https']) | |
end.flatten | |
urls.each do |each| | |
`open #{each}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment