0

I have the following script-snipped, which I use regularly to semi-automate one of my workflows. I open a bash terminal and start irb and then paste the script:

require 'highline/import'

# ...
user = ask("User:")
repo = ask("Repository:")
# ...
# Do advanced fancy stuff

Now I want to be able to paste this into the terminal, but the first prompt for the user is overwritten by the following line: repo = ask("Repository:").

Is there a way to prevent this behaviour.

I know that I could write a script. But

  1. I find it convenient to be able to just paste this into the terminal
  2. I wonder how the STDIN can be somehow outfoxed in this case
Besi
  • 22,579
  • 24
  • 131
  • 223
  • Where do you paste it in from? ;) Wouldn't it be just as convenient to `load` those lines? – Tom Fenech Oct 04 '14 at 10:03
  • @TomFenech I copy this from my notes. I use such script snippets quite often and there is always a terminal open when I am working on a given project. So loading it from some path is not what I want... – Besi Oct 04 '14 at 10:24

1 Answers1

0

Is there a way to prevent this behaviour.

You can prevent the echoing of pasted text with the command

stty -echo

- whether you like that is another question, since this inevitably also prevents the echoing of typed-in commands, but you can see again after entering

stty echo
Armali
  • 18,255
  • 14
  • 57
  • 171