stty -a shows ^Z and ^C but not ^X. Is it not a signal like sigint for ^C and that's why it's not included?
2 Answers
Looking at output from stty -a I count about 15 line discipline characters, only 3 of which generate signals, only 8 are set, and none of them are ctrl-x.
This is because ctrl-x is not a default line discipline character. It is not set by stty but with the bash builtin bind. You can get a full list of those with bind -p
-
What about for intr and susp? I can't find what the tty uses to represent shift and I can't map any of them to two characters ^CV for example. I'm actually trying to swap ctrl + C with ctrl + shift + C and the same for X and CDeoxal– Deoxal2025-02-25 15:58:23 +00:00Commented Feb 25 at 15:58
-
ctrl-cis one character (ascii value 3), not ctrl and c. Similarlyctrl shift cis not available to the tty, only to the GUI and does not have an ascii value, and is usually mapped tocopy.user10489– user104892025-02-26 02:35:53 +00:00Commented Feb 26 at 2:35 -
See as an alternate viewpoint unix.stackexchange.com/questions/785834/…user10489– user104892025-02-26 02:41:00 +00:00Commented Feb 26 at 2:41
The signals as you know are things like sigint and sigtstp. The stty command allows you to tell the tty driver which keys should generate the signals. If for some reason you wanted ^X to generate sigint you could use stty to do so.
If you want to remap what ^X means to bash then you need to look into what man readline or help bind tells you.
-
What about for intr and susp? I can't find what the tty uses to represent shift and I can't map any of them to two characters ^CV for example. I'm actually trying to swap ctrl + C with ctrl + shift + C and the same for X and CDeoxal– Deoxal2025-02-25 15:58:36 +00:00Commented Feb 25 at 15:58
-
The tty driver only allows for a single character to generate a signal. This design goes back to the days when you had to fit the entire OS into 64KB. If you look at the ASCII code you will find it has 128 values. Roughly they are divided into 4 groups of 32. The first group contains the control codes, the next group are numbers and punctuation, the next is upper case and the final group is lower case. This means that say for the letter "b" the code for ctrl-b is 0x02, the code for "B" is 0x42, and the code for "b" is 0x62. 0x22 is a double quote.icarus– icarus2025-02-25 19:16:23 +00:00Commented Feb 25 at 19:16
-
There is no space for a code for ctrl-shift-b, so it uses the code for ctrl-b. Modern systems do have newer input methods which allow for things like multimedia keys. You might be able to map ctrl-shift-c to a value in the 128-255 range and then let stty set that as the interrupt key. I have not tried this and I don't know if it would work.icarus– icarus2025-02-25 19:26:35 +00:00Commented Feb 25 at 19:26