4

I have been using Ctrl+C on most terminals to easily cancel the line I was writing and open the way for a new line. (I'm not talking about killing a running bash script, but just opening a new blank line) For no reason I can think of, this functionality just got turned off on a remote shell opened by SSH.

Ctrl+C will work on most other cases (like killing a running script, exiting VIM insert mode) but will no longer skip the line and go to the next on in the regular shell.

This is a shell running on Amazon linux 2, but I never had this issue on other Amazon Linux 2 machines, so it's probably coming from something I did...

Any idea what might have happened and how I can fix it ?

In the meantime I'm stuck pressing the delete key, which despite putting key repeat time to the minimum, is still quite slow.

EDIT -

I connect to the terminal using SSH, and this is interesting : if I open a new shell inside my SSH terminal (using bash) then CTRL+C works again !

  • Are you sure the terminal emulator is not binding this key? – Konrad Gajewski Sep 03 '18 at 19:57
  • You can try to use Ctrl+U, which should delete everything left of the cursor. – sticky bit Sep 03 '18 at 22:19
  • Does the problem persist if you open a new terminal window and try again? – kasperd Sep 21 '18 at 08:00
  • @kasperd I connect to the terminal using SSH, however and this is interesting, if I open a new shell inside my SSH terminal (using `bash` then CTRL+C works again !) – Cyril Duchon-Doris Sep 21 '18 at 15:29
  • @CyrilDuchon-Doris Not sure how you run `ssh` then. I always open a terminal and type an `ssh` command in that terminal. – kasperd Sep 21 '18 at 16:24
  • I'm using `iterm2` but even if I retype the command on a new terminal folder it has the same bug. I'm using ssh only with the `-Y` flag, but even when removing this flag it doesn't work. So I guess this is just your plain olde SSH. (I don't have the bug on any other SSH session) – Cyril Duchon-Doris Sep 22 '18 at 11:21

1 Answers1

4

To fix it you can use the stty command to reset it.

$ stty intr \^c

To see what intr is currently set you can use:

$ stty -a 

$ stty -a

speed 38400 baud; rows 21; columns 161; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8 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

The function of intr is described in the man page as:

intr CHAR

CHAR will send an interrupt signal

https://linux.die.net/man/1/stty

kenlukas
  • 2,886
  • 2
  • 14
  • 25
  • 1
    Hey, the command `stty intr \^c` does not solve my issue :/. I also see `intr = ^C; quit = ^\ ` in the output of my `stty -a` command – Cyril Duchon-Doris Sep 21 '18 at 15:30
  • 1
    @CyrilDuchon-Doris I see you're using iterm2, there are several references to Ctrl-c not working with iterm2. Search them and see if they fix your issue. – kenlukas Sep 26 '18 at 01:55