Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I reset the bash shell's Ctrl + C keyboard shortcut? I changed it a few months ago and can't seem to recover it.

share|improve this question
add comment

2 Answers 2

The Ctrl+C shortcut used to cancel processes in the terminal is not a bash shortcut, but relates to the tty, as it is a shortcut for one of the signals (SIGINT in this case) that can be sent to processes which are active in the terminal. As noted in this discussion by Wildplasser,

It is the terminal (driver) that intercepts the ^C and translates it to a signal sent to the attached process (which is the shell).

For more on how SIGINT and other POSIX signals are handled, see this in depth article.

As a note, Bash shortcuts like Ctrl+A (to move to the beginning of the line) and others are managed by the readline library; current bindings can be shown by bind -P; see man bash and man readline, or the Ubuntu manpages online. However, even if you also had Ctrl+C set using readline or in your .inputrc, the tty set Ctrl+C would still override it.

However, you should check whether you have changed any keyboard shortcuts in gnome terminal. Go to the menu and click edit > keyboard shortcuts as if you have made one of those Ctrl+C that would override the tty Ctrl+C.


To check current tty bindings run stty -a, which lists, for example,

intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?;
swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;

In order to clear the current binding for the interrupt signal (intr), first run:

stty intr ^- and only then run stty intr ^C to reassign the shortcut.

Make sure you use an upper case C, as this is very important. This is the way to reset the shortcut, but if this still doesn't work you may need to put stty intr ^C in a file and have it read at startup of the terminal, as I discuss in a related answer here.

More general information about Ctrl+C is available in these two Stackoverflow articles:

share|improve this answer
add comment

To reassign the interrupt signal (or SIGINT), call the stty command along with the proper mapping arguments:

stty intr ^c

Source:

share|improve this answer
    
I tried this solution but it wasn't helpful. The Ctrl+C keyboard shortcut in the terminal that kill process unavailable because I changed it . How can I return it back to his original purpose? –  Simpson Nov 3 '12 at 19:03
    
oh ok, i misunderstood the question. editing to address your issue. –  Eliran Malka Nov 3 '12 at 20:32
add comment

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.