top | item 38756466

(no title)

wanderingjew | 2 years ago

If you've ever wondered why it's ctrl+g:

https://twitter.com/ViolenceWorks/status/1335382435031252992...

discuss

order

snvzz|2 years ago

Can't open because twitter, but here's own explanation:

Control-a inputs byte value 1, control-b 2 and so on.

BEL is mapped to value 7 in ascii, thus C-g.

Note control-space usually does input a NUL (0) in most terminals.

susam|2 years ago

Another way to look at it is that Ctrl+G takes the code (ASCII) of G, i.e., 71 (binary 1000111) and toggles its 7th least significant bit to get 7 (binary 111) and indeed 7 is the code of the BEL character.

This explanation is over-simplified though. In practice, different systems have used different techniques to derive control codes from key chords. I have a more detailed article about this at https://susam.net/blog/control-escape-meta-tricks.html if anyone is interested to read it.

Arch485|2 years ago

This was super cool - I've always wondered why the bell character exists/why it's ctrl+G.