0

My terminal does not display ^C when I press CTRL-C in my terminal. I have tried setting various STTY options and am not sure what is wrong.

I am running Mac OSX 10.11.16 and this phenomenon occurs in the Terminal app as well as the iTerm2 terminal emulator. I am not sure where I am going wrong. Here is the output of stty -a:

speed 38400 baud; 39 rows; 171 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;
1
  • 1
    With newer bash versions, it's subject to the echo-control-characters readline option. It's enabled by default, place set echo-control-characters off in ~/.inputrc to disable printing that ^C. Other apps might have their own settings. Simple utilities using the terminal's "cooked" mode rely on stty [-]echoctl.
    – egmont
    May 8 at 16:32

1 Answer 1

4

This depends on the software, and is not consistent. Some shells will merely advance the prompt, others will show the desired ^C (and possibly then exit), and others will emit something besides ^C:

%
%
% tclsh
tclsh> ^C
% clisp
[1]> 
*** - Ctrl-C: User break

[2]> 
% perl -MTerm::ReadKey -E 'ReadMode "raw"; $k=ReadKey(0);' \
  -E 'say "control+c" if $k eq "\003"; ReadMode "restore"'
control+c
% 
1
  • This ended up being correct: I updated to Bash 4.4 (from 3.x) and it is displaying "^C" now. Oct 18, 2016 at 21:22

You must log in to answer this question.

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