I read a lot of answers online that its a bad idea, but the arguments did not make a lot of sense. “it’s a heavily ingrained part of the eco system”. Well if I can change it, what’s the deal?

It makes more sense to make an interrupt signal be the harder shortcut, and copy to be ctrl+C, matching other programs and platforms.

  • d3Xt3r@lemmy.nzM
    link
    fedilink
    arrow-up
    277
    arrow-down
    2
    ·
    edit-2
    11 months ago

    matching other programs and platforms

    Actually, Ctrl+C is the interrupt hotkey for pretty much every CLI app/terminal on every platform. Try it within the Command Prompt/PowerShell/Windows Terminal, or the macOS terminal - they’ll all behave the same.

    The use of Ctrl+C as an interrupt/termination signal has a very long history even predating the old UNIX days and DEC - it goes back to the days of early telecommunications, where control characters were used for controlling the follow of data through telecommunication lines. These control characters, along with regular characters, were transmitted by being encoded in binary, and this encoding scheme was defined by ASCII (American Stanard Code for Information Interchange), published in 1963.

    In ASCII, the control character ETX (meaning end-of-text; represented by the hex code 0x03) was used to indicate “this segment of input is over”, or “stop the current processing”.

    Now what does all this have to do with with Ctrl+C you ask?

    For that, you’ll need to go back to the days of early keyboards. Keyboards back then generated ASCII codes directly, and when a modifier key (Ctrl/Shift/Meta) on a keyboard was pressed in combination with another key, it modified the signal sent by the keyboard to produce a control character.

    Specifically, pressing Ctrl with a letter key made the keyboard clear (set to zero) the upper three bits of the binary code of the letter, thus effectively mapping the letter keys to control characters (0x00 - 0x1F: the first 32 characters on the ASCII table).

    • The ASCII code for ‘C’ is 0x43 (binary 01000011).
    • Pressing Ctrl+C clears the upper three bits, resulting in 00000011, which is 0x03 in hex.

    And would you look at that, 0x03 is the code which represents the control character ETX.

    The use of ETX to interrupt a program in digital computers was first adopted by the TOPS-10 OS, which ran on DEC’s PDP-10 computer, back in the late 60s. It’s successor, TOPS-20 also included it, followed by the RSX-11 (on the PDP-11), and VMS (on the VAX-11).

    RSX-11 was a very influential OS, created by a team that included David Cutler. It influenced the design of several OSes that followed, such as VMS and Windows NT. Cutler later moved to Microsoft and became the father of Windows NT. Early NT did not include a GUI, so it was natural to adopt existing terminal operation standards, including the use of ETX. In fact, NT’s internals were so similar to VMS that a lawsuit was in the works, but instead, MS agreed to pay off DEC millions of $$$.

    Also, when UNIX first came out (1969), it ran on DEC hardware, and so they followed the tradition of using the ETX signal to stop programs. This convention flowed to BSD (1978) which was based on UNIX, and NeXTSTEP (1989), which was based on BSD. NeXTSTEP was developed by NeXT Computers, which was founded by Steve Jobs… and the rest is history.

    Therefore, Ctrl+C is something that’s deeply rooted in history. You don’t just simply change something like that. Sure, you may be able to remap the keybindings, but it’s actually hardcoded into many programs so you’ll run into inconsistencies - that is, if you used the standard remapping tools built into GNOME/KDE etc.

    If you want to truly remap Ctrl+C, you’ll want to do so at a lower level (evdev layer) so that it’s not intercepted by other programs, eg using tools like evremap or keyd. But even then, it’s not guaranteed to work everywhere, for instance, if you’re inside a VM or using a different OS, or in a remote session. So it’s best to remap the keys at the keyboard layer itself, which is possible on many popular mechanical keyboards using customisable firmware like QMK/VIA.

    • fartsparkles@sh.itjust.works
      link
      fedilink
      arrow-up
      29
      ·
      11 months ago

      Best comment I’ve read on Lemmy in weeks. Thought provoking, enlightening, and incredibly well written. Thank you for hanging out here.

    • Enoril
      link
      fedilink
      arrow-up
      16
      ·
      11 months ago

      Bravo, very good explanation! As fun fact, i still have at work several DEC ALPHA and OpenVMS servers (some are now VM but we still have physical servers from this era managing our data) and Ctrl+C works well!

    • murtaza64@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      11 months ago

      Switching it at the terminal emulator level should work fine for every CLI/TUI though, right? Just have your terminal send 0x03 when you press C-S-c and copy selected text on C-c. I haven’t tested it but I’m sure that alacritty, wezterm, windows terminal and probably tmux can do this.

    • laurelraven@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      1
      ·
      10 months ago

      I will point out that in modern Windows terminals, Ctrl+C does copy selected text if there’s text selected; personally, I don’t see a problem with having it be context aware like that to make it behave more like how the majority of current users will be expecting based on how programs outside the CLI behave

    • matcha_addict@lemy.lolOP
      link
      fedilink
      arrow-up
      9
      ·
      11 months ago

      Ctrl+Insert gets pretty close, but some laptops, including Mac books, don’t have insert on their keyboard. 😔

        • matcha_addict@lemy.lolOP
          link
          fedilink
          arrow-up
          3
          ·
          11 months ago

          Command+C on Mac books work, yes, But that still means inconsistencies across different platforms. I am forced to use macos for work, and I try to unify my shortcuts across the two platforms. Otherwise it’s disorienting using my personal computer after a day of work

          • murtaza64@programming.dev
            link
            fedilink
            arrow-up
            1
            ·
            11 months ago

            My solution for this has been on my Linux machine, using keyd, to swap alt and super, and map super+c, super+v to copy and paste. (I also map super+L, super+R, super+T and super+W in Firefox to the control- equivalents using keyd’s per-application bindings functionality)

    • Papamousse@beehaw.org
      link
      fedilink
      arrow-up
      1
      ·
      11 months ago

      Yep, I’m using ctrl-c and q and s and d and z etc for almost 40 years now, it would be difficult to change those habits

  • Max-P@lemmy.max-p.me
    link
    fedilink
    arrow-up
    32
    arrow-down
    1
    ·
    11 months ago

    The thing about “it’s a heavily ingrained part of the eco system” is that, it really is. We’re not talking about user habits here, we’re talking the whole ecosystem of software that expects it to work that way: the kernel, the shells, SSH, the terminal emulators, the virtual consoles.

    Under the hood, those aren’t keyboard shortcuts, they’re control characters and you make those with Ctrl plus a key, and it’s handled by the kernel itself so you’d have to run a custom kernel on every machine you use just so you can use Ctrl+C for copy.

    So, on the wire those have to stay. You can configure your terminal emulator to maybe swap Ctrl and Super as super doesn’t mean anything for a terminal. That’s pretty much how things happen to be on macOS, since copy/paste is Super+C/V. Then your Ctrl key is free for anything you might want.

    Some extra docs about all the codes: it’s far from just ^C: https://man7.org/linux/man-pages/man4/console_codes.4.html

    • matcha_addict@lemy.lolOP
      link
      fedilink
      arrow-up
      5
      arrow-down
      2
      ·
      11 months ago

      Isn’t it enough just to instruct stty to take the new shortcut, instead of running a custom kernel? Is there anything left out by doing this?

      • cally [he/they]@pawb.social
        link
        fedilink
        English
        arrow-up
        3
        arrow-down
        1
        ·
        11 months ago

        idk it’s weird to have ^C, ^M and other control characters and have one be ctrl+shift+c and the other be control+m

        • matcha_addict@lemy.lolOP
          link
          fedilink
          arrow-up
          4
          ·
          11 months ago

          It shouldn’t be too difficult to remap them all to the ctrl+shift equivalent. I just have to make sure I get all of them.

  • z00s@lemmy.world
    link
    fedilink
    arrow-up
    28
    ·
    11 months ago

    The “why” doesn’t matter. If you don’t like it, change the shortcuts on your own machine. That’s the beauty of Linux.

  • taladar@sh.itjust.works
    link
    fedilink
    arrow-up
    28
    arrow-down
    1
    ·
    11 months ago

    It is a bad idea to get used to using Ctrl+C as copy on the terminal because then you will accidentally abort programs all over with muscle memory on systems you haven’t twisted beyond recognition customized.

    • matcha_addict@lemy.lolOP
      link
      fedilink
      arrow-up
      9
      ·
      11 months ago

      That’s a valid point. I already have a similar but not exactly the same problem when I move between linux and macos, where the shortcuts don’t really match or work.

      The difference between ctrl+C on the browser and ctrl+C on the terminal already disorients me. I’d rather the shortcut work the 99% of the time I’m on my own machines.

      I think I’ll just have to really keep this in mind when not using my own machine.

      • atzanteol@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 months ago

        I used to create tons of aliases and custom helper scripts. It became a real pain whenever I worked on a Linux server or something that didn’t have all my customizations. Now I only have one alias (l=“ls -Fhla”). Getting used to my snowflake system just made things more complicated for me…

    • beirdobaggins@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      11 months ago

      I use the terminal so much that I frequently accidentally use Ctrl-Shift-C and V outside of the terminal.

      Ctrl-Shift-V usually works pretty well as it does a paste without formatting in a lot of places.

      Accidentally hitting Ctrl-Shift-C though in a MS Team’s chat though, starts a voice call with all chat participants. 😑 hate it

  • Deckweiss@lemmy.world
    link
    fedilink
    arrow-up
    7
    ·
    edit-2
    11 months ago

    I’ve done it for about a decade without anything bad ever happening.

    I have rebound copy and paste to ctrl+c and ctrl+v in konsole and bound the interrupt to ctrl+x using stty intr ^x

    Also I keep it consistent across ssh sessions by using Xpipe.

    I honestly wasn’t even aware that anybody thought it might be bad for any reason.

    • Possibly linux@lemmy.zip
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 months ago

      Why? It seems like you would want to kill a program more than copying text. Is it just a habit thing?

      • Deckweiss@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        11 months ago
        1. Not in my workflow. Usually programms terminate after doing their job. And I copy the output all the time to google for stuff or to put it in another terminal or another command.

        2. Ctrl+X is not significantly more difficult to press than Ctrl+C. But Ctrl+Shift+C is.

  • NeoNachtwaechter@lemmy.world
    link
    fedilink
    arrow-up
    3
    arrow-down
    23
    ·
    11 months ago

    I read a lot of answers online that its a bad idea, but the arguments did not make a lot of sense.

    If you want to understand, look for original reason, not for answers to your own little questions.

      • Kanedias@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        10 months ago

        He means that ASCII table has an actual character that represents end-of-text and that terminals respond to with SIGINT, and it is ETX character, 0x03.

        The Control modifier on your keyboard basically clears the top three bits of whatever ASCII character you type, leaving the bottom five and mapping it to the 0…31 range. Ctrl+C sends 0x03, which is exactly ETX.

        Look at the ASCII table for a clue, this is why it was a convenient thing to do.