Skip to content

Instantly share code, notes, and snippets.

@hboon
Created July 11, 2023 00:22
Show Gist options
  • Save hboon/bea96acb8dd31cf0f45cfd0ae444774f to your computer and use it in GitHub Desktop.
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)
#!/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