5

When you're editing a prompt in bash, and then press Ctrl-C to abort it, "^C" might get printed where the cursor has been.

When you were in the middle of the line, this makes copy'n'pasting more difficult and IIRC it can be configured to not display it (and overwrite parts of the command line).

I do not have this problem myself (using zsh, which does not print "^C"), but ran across this in a Konsole bug report.

quack quixote
  • 42,186
  • 14
  • 105
  • 129
blueyed
  • 1,201
  • 11
  • 20
  • this happens to me in the current Ubuntu 10.04 under gnome-terminal and on an actual VT. i haven't fully tested, but it doesn't happen in the same gnome-terminal when SSH'd into a Debian system. – quack quixote May 30 '10 at 01:02

1 Answers1

11

Give this a try:

stty -ctlecho

You can add that to your ~/.bashrc.

Dennis Williamson
  • 106,229
  • 19
  • 167
  • 187
  • 1
    checking with *stty -a* indicates the **echoctl** option is set; the manpage verifies **echoctl** and **ctlecho** are synonyms; running this command unsets the option. thanks! – quack quixote May 30 '10 at 01:19
  • This works, but is probably a more general setting than only for this special case (aborting the command editing), isn't it? – blueyed May 30 '10 at 01:20
  • @blueyed: Yes, it's more general. – Dennis Williamson May 30 '10 at 03:01
  • @blueyed: i checked my bash's current *readline* settings for C-c, but found nothing. this is the only thing i've found that affects the issue, but maybe someone else will know of a more targetted fix. – quack quixote May 30 '10 at 18:28
  • @quack quixote: There aren't any readline variables that affect this and though you can bind ^C to a readline function or macro but it won't do anything because the terminal driver controls its function. – Dennis Williamson May 30 '10 at 20:13
  • @Dennis: yeah, that's what it looked like to me, thanks for verifying. if i understand correctly, ^C is interpreted by the terminal driver as sending SIGINT, which you can trap with *trap*, or reassign with *stty intr NEWCHAR* ... – quack quixote May 30 '10 at 20:52
  • @quack quixote: That's correct. – Dennis Williamson May 30 '10 at 23:42