Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
st0012 opened this issue Nov 8, 2023 · 1 comment · May be fixed by #1044
Open

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

st0012 opened this issue Nov 8, 2023 · 1 comment · May be fixed by #1044
Labels
enhancement New feature or request rubyconf-hackdays

Comments

@st0012
Copy link
Member

st0012 commented Nov 8, 2023

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
@st0012 st0012 added enhancement New feature or request rubyconf-hackdays labels Nov 8, 2023
@amomchilov
Copy link

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

Prajjwal added a commit to Shopify/irb that referenced this issue Dec 11, 2024
@Prajjwal Prajjwal linked a pull request Dec 11, 2024 that will close this issue
Prajjwal added a commit to Shopify/irb that referenced this issue Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rubyconf-hackdays
Development

Successfully merging a pull request may close this issue.

2 participants