Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I paste into the terminal, sometimes what is in the clipboard is not what I expected. Specifically, it is sometimes pages and pages of text from a website.

When this happens, the terminal goes crazy, blinking rapidly and spitting out command not found as fast as it can.

I am afraid that someday the text will contain something like rm -rf /.

What is the best way to:

  • act when I make such a mistake?
  • prevent such a mistake from occurring?

For details, I use bash in GNU screen windows in a urxvt terminal on Linux.

The usual Ctrl-C or Ctrl-Z have no effect in my experience.

share|improve this question
I break a cold sweat every time it happens to me... Don't work under root and have backups. I also use a "scrap" file in a text editor to test what I copied from a web site, since with browsers you can never be sure what exactly you just copied. – haimg Nov 9 '11 at 6:35
up vote 5 down vote accepted

To safely paste, you could invoke a text editor in bash using CTRL-X E. The shell builtin fc will bring up an editor with the last command.

Short of killing the shell/terminal, I am not sure if there is any way to kill something after you have pasted something in, and it has gone wrong.

share|improve this answer

Using urxvt makes this very easy. Simply enable confirm-paste in your .Xresources.

URxvt.perl-ext-common: confirm-paste,

I think it comes with certain packages of urxvt or urxvt perls... But once enabled it will ask you to hit y or n on paste of primary or selection buffers, and display a line count. So if you see a million lines you can just quickly hit n and be done with it.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .