You are not logged in.

#1 2022-01-29 09:10:45

Trevor_B
Member
Registered: 2019-12-28
Posts: 141

[Solved] Disable Ctr+C or change it

Is there a way that I can disable Control+C in terminal ? or better still change it to a Ctr+Alt+C for instance

I sometimes what to copy a part of terminal text and I still do Ctr+C by error and sometimes before the procedure has finished, Today an update, corrupting my system (Whoops - ==> dkms install --no-depmod nvidia/470.94 -k 5.16.3-arch1-1
^C)

So If I could change the Ctr+C to Ctr+Alt+C for instance that would be nice

Thanks

Update :  Reading around, thanks Google

I modified my bash file  (.bashrc) in my home directory

adding :
stty intr undef

Works Ok, Is there's a better  / cleaner way, or is this just fine ? .

Last edited by Trevor_B (2025-03-09 14:55:16)

Offline

#2 2022-01-29 10:36:40

mpan
Member
Registered: 2012-08-01
Posts: 1,593
Website

Re: [Solved] Disable Ctr+C or change it

Trevor_B wrote:

Works Ok, Is there's a better  / cleaner way, or is this just fine ? .

Re-wiring your brain. Just get rid of the habit of using Ctr+C for that purpose in a terminal. It’s much more effective than going against the stream.

While this advice is not true in general with UIs breaking user habits, in this case it’s the other way around: Ctr+C generating SIGINT is a de facto standard and it predates its use in GUI applications. It’s so ubiquitous that many programs will expect you to be able to use Ctrl+C for that purpose as part of their normal operation. And everyone around trying to help you will be confused by your Ctrl+C not working or — worse — you not being able to generate SIGINT.

In terminal most keys pressed with Ctrl alone are expected to produce some value that is passed directly to the program. Ctrl+D is another commonly used one.

Last edited by mpan (2022-01-29 10:37:27)


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#3 2022-01-29 14:00:00

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [Solved] Disable Ctr+C or change it

I'll offer a counter-point to the above.  No command line program expects to be able to recieve a Ctrl-C keypress; quite the opposite really.  Due to it's de facto standard use by terminals / terminal emulators, programs running in the terminal should expect to not ever be able to receive such a key combination.  They can receive a SIGINT, and that may be an important part of their operation.  So you definitely want a way to readily send a SIGINT to the program running in the terminal.  The OPs proposal of using Ctrl-Alt-C for this purpose is perfectly reasonable.

Anyone around you trying to help you should not be confused by this as you'll know if / when they say to press "Ctrl-C" you really need to press "Ctrl-Alt-C".  Unless of course they move you away from your computer and grab your keyboard without even consulting you.  In that case, the resulting "confusion" should be the least of their concerns.  Of course, one could argue that if this is a shared system, it might cause issues for other users of the system.  But I'd suggest that users of a shared arch system pretty much always fall into one of two categories: 1) other competent linux users who are comfortable in the terminal, and 2) "casual" computer users who primarily just want a web browser (e.g., not-so-tech-oriented family members).

In the case of the former, they'd probably have their own user account on the computer (or if they don't yet, they should) and the configs you put in place for your user's terminal emulator should be none of their business.  For the latter, they probbaly wont be running programs in the terminal, and they most likely wouldn't know the SIGINT use of Ctrl-C anyways.

So go for it.  It sounds like a sound plan to me to remap these keys.  But this would not be by using `stty` to ignore sigint because you do want to be able to send sigint somehow (with Ctrl-Alt-C).  Actually Ctrl-Alt-C will already result in a sigint, so all you need to do is get your terminal emulator to capture Ctrl-C presses while allowing Ctrl-Alt-C presses to pass through as normal.  This is certainly possible in terminal emulators with good keybinding configuration settings - but exactly how to do it will depend on the terminal.

Perhaps an alternative would be to use `stty` to set some other character to be the sigint trigger then just find a key combination to get your terminal to send that character.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2022-01-29 16:01:11

Trevor_B
Member
Registered: 2019-12-28
Posts: 141

Re: [Solved] Disable Ctr+C or change it

Thanks for the input

I've changed the ^c to ^i
(i for interrupt) seems logical in my case/head.. As I am the only user of this computer it won't / can't disturb anyone else

Thanks again for your input

Offline

#5 2022-01-29 16:29:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [Solved] Disable Ctr+C or change it

Sounds great.  Was this just via `stty` (incase anyone else finds this thread with the same goal)?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2022-01-29 16:44:43

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,287

Re: [Solved] Disable Ctr+C or change it

iirc ^i is tab?
Does the tab key now fire a sigint?

Offline

#7 2022-01-29 17:09:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [Solved] Disable Ctr+C or change it

True - I was thinking of recommending an unused (or very rare) character like vertical tab (which would be ^k).  Perhaps ^b would be good as SOT is not really used as far as I know, and it has a useful mnemonic of b=break.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2022-01-29 18:04:16

Trevor_B
Member
Registered: 2019-12-28
Posts: 141

Re: [Solved] Disable Ctr+C or change it

Trilby wrote:

Sounds great.  Was this just via `stty` (incase anyone else finds this thread with the same goal)?


Yes just added stty intr ^i in my bashrc file,

Tested it, seems to works perfectly

$ stty -a
speed 38400 baud; rows 25; columns 90; line = 0;
intr = ^I; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>;

Last edited by Trevor_B (2022-01-29 18:05:10)

Offline

#9 2022-01-29 20:43:34

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,287

Re: [Solved] Disable Ctr+C or change it

Do you understand the concerns about choosing ^i that we touched on in#6 & #7?

Offline

#10 2022-01-30 08:54:51

Trevor_B
Member
Registered: 2019-12-28
Posts: 141

Re: [Solved] Disable Ctr+C or change it

seth wrote:

Do you understand the concerns about choosing ^i that we touched on in#6 & #7?


Hi
Many thanks for jumping in here

Wasn't sure exactly what you meant, but effectively, TAB would stop as well (fires the sigint like ^I), so I've changed it back to Ctr+C until I find a better letter to suit my needs

I did a stty sane to reset and have "# stty intr ^i" until I get this right or rather find a letter other than C  (which I still do not appreciate...)

PS Found this page, https://www.baeldung.com/linux/sigint-a … on-signals

Helpful though I must admit I do not understand it all

Phew smile

Offline

#11 2022-01-30 09:13:23

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,287

Re: [Solved] Disable Ctr+C or change it

I agree w/ Trilby that ctrl+b (start of text) sounds like a good choice (start of text is NOT pos1)
https://www.physics.udel.edu/~watson/scen103/ascii.html

Last edited by seth (2022-01-30 09:14:10)

Offline

#12 2022-01-30 10:03:29

Trevor_B
Member
Registered: 2019-12-28
Posts: 141

Re: [Solved] Disable Ctr+C or change it

Thanks B=Break is fine , a good idea

Have modified it and even added a small Conky file to my desktop to remind myself of certain commandes (with age I forget.....)
Break [Ctr+B]
Suspend [Ctr+S]
Continue [Ctr+Q]
Stop [Ctr+Z]

Offline

#13 2025-06-03 07:24:36

squrelinux
Member
Registered: 2025-06-03
Posts: 1

Re: [Solved] Disable Ctr+C or change it

@mpan Remember you're the Linux paradox. You're angry why people don't use linux and use windows and mac, but, you're the one who treats newbs like idiots for wanting to do something they believe is intuitive. You like to live in the 70s 80s and use Ctrl+C for interrupt instead of copy? That's fine. But when someone asks if it is possible to overwrite that, which is possible, you either answer how or go back to your goon cave and be quiet. Did you know that most people don't know that the save icon is a floppy disk? Should they then only save to floppy disks because it predates SSDs?

Offline

#14 2025-06-03 08:15:28

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,156

Re: [Solved] Disable Ctr+C or change it

Why you felt the need to dig up a three year old solved thread to stirr irrelevant drama - the point of which has already been adressed when the thread was active - is anyones guess but maybe take your own cave advice.

https://wiki.archlinux.org/title/Genera … bumping%22
https://terms.archlinux.org/docs/code-o … o-trolling

Closing. Warned for trolling

Offline

Board footer

Powered by FluxBB