When I'm running a program I am used to killing it with ctrl-c, then pressing the up arrow in order to recover a previous command line, and then editing the text and running again. In Ubuntu 14.04 when I use backspace and type in new letters what I'm seeing in the terminal and what is actually getting run is not the same. Pressing ctrl-c and up after running the new bad command line reveals the garbled text of what was really executed- it looks like where I though the cursor is and where the terminal had it actually were in disagreement.

If I press ctrl-c a second time after the application quits I'll get back to a clean command line and can press up and edit normally. I believe this didn't need to be necessary, is there a setting I can change to also result in a good command line?

GNOME Terminal 3.6.2

$ stty -a
speed 38400 baud; rows 48; columns 100; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?;
start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

1 Answer 1


What's happening is that the interrupt is outputting characters on the new line, so the prompt isn't starting at the beginning of that line. The result is that the place on the line where the shell editing function thinks you are isn't actually where you really are.

The easy solution is to do something like Ctrl CEnter before hitting your up arrow for re-entering the most recent command line. Or continue with your Ctrl CCtrl C method, which has the same net result but is probably quicker to type.

You must log in to answer this question.

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