Skip to content

Instantly share code, notes, and snippets.

@baweaver
Created December 2, 2018 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baweaver/8fe87a645be2147ec8e295690391ef0c to your computer and use it in GitHub Desktop.
Save baweaver/8fe87a645be2147ec8e295690391ef0c to your computer and use it in GitHub Desktop.
Pasting in Pry with TMUX

Step 1: Make sure you have pbpaste and pbcopy ready and that tmux is configured to behave itself: https://evertpot.com/osx-tmux-vim-copy-paste-clipboard/

Step 1.b: The config is slightly borked due to new versions, see this issue: tmux/tmux#754

Step 2: In your .pryrc do this:

def pbcopy(input)
  str = input.to_s
  IO.popen('pbcopy', 'w') { |f| f << str }
  str
end

def pbpaste
  `pbpaste`
end

Pry::Commands.block_command 'paste_eval', "Pastes from the clipboard then evals it in the context of Pry" do
  _pry_.input = StringIO.new(pbpaste)
end

Step 3. Do this in Pry and enjoy: paste_eval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment