Skip to content

Instantly share code, notes, and snippets.

@hboon
Created July 11, 2023 00:22
Show Gist options
  • Select an option

  • Save hboon/bea96acb8dd31cf0f45cfd0ae444774f to your computer and use it in GitHub Desktop.

Select an option

Save hboon/bea96acb8dd31cf0f45cfd0ae444774f to your computer and use it in GitHub Desktop.

Revisions

  1. hboon created this gist Jul 11, 2023.
    15 changes: 15 additions & 0 deletions openurls.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/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