Skip to content

Explore the possibility to add a command to copy evaluation result #753

Closed

Description

@st0012

It could be very helpful to have a command to copy IRB's output without manually selecting a (potentially huge) chunk of text. For example:

copy User.all.to_a # copies and echos all users
copy User.all.to_a; # copies and doesn't echo all users
copy _ # copies the previous output value

Things to consider:

  • We cannot rely on any non-default Ruby gems
  • We may use system commands if they're widely available, at least among UNIX-based systems

Activity

  1. amomchilov commented on Oct 11, 2024

    @amomchilov

    macOS only

    I mimic this by adding these two methods to my ~/.irbrc, which use the pbcopy and pbpaste command line utilities.

    # Copies the input to the user's clipboard.
    def pbcopy(input)
      str = input.to_s
      IO.popen('pbcopy', 'w') { |f| f << str }
      str
    end
    
    # Returns a string containing the contents of the user's clipboard.
    def pbpaste
      `pbpaste`
    end
  2. added 2 commits that reference this issue on Dec 11, 2024
    565421b
    7affd25
  3. added 8 commits that reference this issue on Jan 12, 2025
    8819e5e
    1b409ba
    914962e
    590af2b
    0f721f1
    f0faf98
    f308c9e
    b4eb6be
  4. added 3 commits that reference this issue on Jan 21, 2025
    a24ac53
    3b3517b
    c6e8ee4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions