tags:

views:

295

answers:

2

How do I tell my bash to not echo ^C back to terminal?

If I just hit Ctrl+C in bash session, nothing is printed in my terminal window. But if I terminate some program with Ctrl+C, sometimes ^C is echoed and printed in my terminal. Is there any way to tell my bash I do not want echoing back ^C at all?

+1  A: 

Well, I believe it's actually echoing "caret"-C, not the CTRL-C character. Other than that, this is actually a function of the tty driver, not the shell; the driver actually intercepts the CTRL-C character, generates a SIGINT to the process, and echos the characters. If there is a way to do it on your system (this will be heavily OS dependent) it would be documented in the stty(1) man page or the tty(4) driver page.

Charlie Martin
Thank you. Changing the output with stty works as I wanted it to on OS X, I have still something missing on Linux.
zgoda
Well, I said it was heavily system dependent. At least now you're looking in the right place.
Charlie Martin
+2  A: 

Under Linux:

stty -ctlecho

(props to Charlie for the hint - I just went and looked it up)

Andy
or -echoctl because who wants just *one* flag.
Charlie Martin
Well, on my linux box (Ubuntu 8.10) it just changes the output from "^C" to some other character(s), apparently dependent on terminal encoding. On OS X box, manpage says it will echo the CTRL-something "as themself" and works as expected.
zgoda