1

How can I disable the key combination Ctrl+C on GNU-screen? Actually I would have to get used to it, but I press Ctrl+C rather than Ctrl+A+D out of habit.

migrated from serverfault.com Dec 14 '18 at 21:05

This question came from our site for system and network administrators.

2

Ctrl+C sends the INT (interrupt) signal to the process currently in the foreground. This is an important signal to be able to send, so the best thing would be to just learn not to press that key combination by mistake.

You can also remap that key combination so that you have another control sequence that sends the INT signal. For example, you may make Ctrl+G do the same thing with the shell command

stty intr ^G

The Ctrl+C key combination will then just send a character with ASCII code 3.

Again, it would probably be less problematic to just learn to use Ctrl+C correctly.

  • Thank you. I'll take care of it. Unfortunately I can only use your command outside of screen. A Java or Python program runs inside. I have already pressed the wrong key combination so often that I have to do something. ;) – uav Dec 17 '18 at 11:06
  • @uav Ah. If you are able to modify the code of the program, you could make it ignore the INT signal completely. – Kusalananda Dec 17 '18 at 11:20
  • That is possible, but I have posted a more general answer. ;) – uav Dec 17 '18 at 16:03
0

Now I've found the answer myself. The instructions

defscrollback 30000
bindkey "^C" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'
bindkey "^D" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'
bind "^M" quit

in the file

~/.screenrc

lead to the fact that C-c only executes the echo command, thus no longer sends an interrupt. The advantage of this solution is that I don't have to change the actual Java or Python program. Please remember that running screen sessions must be restarted in order to read the new ~/.screenrc file. (This path depends on the user, e.g. /root/.screenrc or /home/user/.screenrc.)

Helpful links:

Tested with

  • Screen version 4.01.00devel (GNU) 2-May-06
  • Ubuntu 14.04.5 LTS
  • MobaXterm v10.9 Build 3656 (Windows)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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