You're logged in from home, running a program, and answering a prompt.
As you're almost done, modem noise prints
xDxD@! on your screen.
Where were you?
Or you're typing a long command line and a friend interrupts you with
to say it's time for lunch.
Do you have to press
and start typing over?
If your system understands the rprnt character (usually set to CTRL-r), you can ask for the command line to be reprinted as it was. In fact, you can use CTRL-r any time you want to know what the system thinks you've typed on the current line - not just when you're interrupted. But this only works in the normal input mode; programs like vi that do their own input processing may treat CTRL-r differently. Here's an example:
egrep '(10394|29433|49401)' /work/symtower/Message from alison@ruby on ttyp2 at 12:02 ... how about lunch? EOF
[CTRL-r] egrep '(10394|29433|49401)' /work/symtower/logs/*
After the interruption, I just pressed CTRL-r. It reprinted the stuff I'd started typing. I finished typing and pressed RETURN to run it.
If you use a shell like the Korn shell that has interactive command editing, you can probably use it to reprint the command line, too. In bash, for example, from vi editing mode, CTRL-r still seems to start an Emacs-style reverse search. So I added this fix to my ~/.inputrc file:
# By default, ^R seems to do a "reverse-i-search", # even when not editing! Workaround: "\C-r": redraw-current-line