Sha256: a1b4e5f9e2bfef96581832d34709ee6c582dcbfad38de585a07c11c3efda3363

Contents?: true

Size: 477 Bytes

Versions: 1

Compression:

Stored size: 477 Bytes

Contents

require "clipboard"

def depryve(argv=[])
  # Defined in this scope so that nothing extraneous is created
  # when this gem is required in a REPL session
  prompt = /\A(irb|\[\d+\] pry)/

  # Use X11 primary selection by default
  selection = argv.include?("-c") ? :clipboard : :primary

  Clipboard.copy(Clipboard.paste(selection).lines.select { |ln| ln =~ prompt }.map do |line|
    line.gsub(/#{prompt}[^ ]+ ?/, "")
  end.join.strip)
end

def depryve_c
  depryve ["-c"]
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
depryve-0.2 lib/depryve.rb