Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is the opposite of Prevent “^C” from being printed when aborting editing current prompt.

I'm using Bash. When I'm editing the commandline in Bash, and I hit Control-C to abort the commandline, the '^C' character does not display. I would like to see this character.

I tried commands like stty -ctlecho and stty ctlecho (which I borrowed from the other question), but this didn't work for me. This behavior seems to be true with my environment on Ubuntu, CentOS and MacOSX. This only happens within Apple's Terminal.App. If I SSH to a remote Linux or FreeBSD box, then ^C is printed. So, this is clearly just a local setting.

Update:

Here is the output of stty -a, as requested by @quack quixote :

$ stty -a
speed 9600 baud; 41 rows; 88 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
 -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
 -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
 -ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
 -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
 eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
 min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
 stop = ^S; susp = ^Z; time = 0; werase = ^W;

After typing stty sane, stty -a will output the following. The only difference is the parameter of -iutf8.

$ stty sane
$ stty -a
speed 9600 baud; 41 rows; 157 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
    -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
    -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -iutf8
    -ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
    -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
    eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
    min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
    stop = ^S; susp = ^Z; time = 0; werase = ^W;
share|improve this question
    
if you haven't tried "stty echoctl", do so. "echoctl" should be synonymous with "ctlecho", but on some systems it may not be. check both to make sure. if you that doesn't help, please post the output of "stty -a" into your question. –  quack quixote Jun 2 '10 at 2:20
    
How are you accessing these systems? PuTTY, gnome-terminal, xterm, console? –  Dennis Williamson Jun 2 '10 at 4:33
    
@Dennis Williamson : I'm using the Apple Terminal.App, and I'm either on the local system or I am SSH'd into a remote system. I think this happens with gnome-terminal as well, but I'm not certain. –  Stefan Lasiewski Jun 2 '10 at 15:44
1  
It sounds like this may be specific to Terminal.app. I don't have access to a Mac right now, so I can't check on this. Have a look at the configuration options for Terminal.app to see if you can find something relevant. –  Dennis Williamson Jun 2 '10 at 22:55
    
@Dennis Williamson: You are correct. This only happens on Terminal.App. Gnome Terminal works fine. –  Stefan Lasiewski Jun 12 '10 at 4:10

2 Answers 2

Just compared my outputs with yours from "stty -a" both with and without stty sane and come to the same conclusion: only difference is -iutf8.

However, for me the ^C does get printed when terminating a running command with CTRL + C on my MBP, running 10.6.4:

uname -a Darwin noname 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386

share|improve this answer

Based on Aesthir's answer on a related question, I came up with the following which works great on both my OS X 10.8 and Debian machines:

trap '{ echo -n "^C" >&2; }' SIGINT
stty -echoctl
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.