• ClownStatue@piefed.social
        link
        fedilink
        English
        arrow-up
        1
        ·
        4 months ago

        Unless you’re in a default screen session (I always thought ^A was such a dumb default for screen to use).

          • ClownStatue@piefed.social
            link
            fedilink
            English
            arrow-up
            2
            ·
            edit-2
            4 months ago

            Maybe someone who only used csh? I can’t remember if ^a is a default in that shell. I thought it started with ksh or bash.

            ETA: just looked it up and I’m dumb. Comes from emacs (of course) and looks like it was introduced in bash. I guess I could claim ignorance, being a VI man, but I actually knew at some point that it came from emacs. I think I can count on 1 hand the number of times I’ve used emacs

    • Ephera@lemmy.ml
      link
      fedilink
      arrow-up
      1
      ·
      4 months ago

      Always amused me that sudo !! is actually more keypresses (at least on keyboards where typing ! requires holding Shift).

      • printf("%s", name);@piefed.blahaj.zone
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        4 months ago

        You just blew my mind. sudo [space] [shift] !! [enter] (4+1+1+1+1+1) is one keypress longer than ↑ + home + sudo + space + enter (1+1+4+1+1). In your face, universe.

        • gankouskhan@piefed.zip
          link
          fedilink
          English
          arrow-up
          4
          ·
          3 months ago

          Actually, after kinematic analysis of the required fingertip trajectories upheaves both of these arguments. If you calculate the aggregate spatial displacement across a standard 2D Euclidean plane for both input strings, the former macro sequence yields a significantly lower metric footprint than the latter.

          For the sake of empirical demonstration, we can map this across a standard ANSI 100% layout using a normalized key pitch constraint where 1 U = 19.05 mm. By establishing a Home Row Idle-State Matrix as our behavioral anchor and tracking independent multi-finger vectors using the standard Pythagorean metric tensor—calculating the straight-line distance d = sqrt( delta_x^2 + delta_y^2 ) between consecutive keystroke coordinates—we arrive at the following quantitative breakdown:

          Macro Sequence 1: sudo [shift] !! [enter]

          • Single-Handed Vector String: 40.878 U
            • Net Linear Displacement: 778.7 mm
          • Dual-Handed Touch-Typing Matrix: 8.424 U
            • Net Linear Displacement: 160.5 mm

          Macro Sequence 2: [up] [home] sudo [space] [enter]

          • Single-Handed Vector String: 40.989 U
            • Net Linear Displacement: 780.8 mm
          • Dual-Handed Touch-Typing Matrix: 21.728 U
            • Net Linear Displacement: 413.9 mm

          tl;dr

          Fewer keystrokes != less work. Even though typing !! looks like more work, it isn’t because your finger travel distance is significantly shorter when executing those keys using two-handed touch typing on a standard ANSI QWERTY keyboard.

          • printf("%s", name);@piefed.blahaj.zone
            link
            fedilink
            English
            arrow-up
            3
            ·
            edit-2
            3 months ago

            Edit: I will forward your thesis to the cat.

            My day started out catastrophically bad, resulting in taking a sick day.

            Then came you.

            I cried and laughed in some sequence and it gave me the energy to get out of bed. Now, I will have breakfast*.

            *Loose definition.

            • gankouskhan@piefed.zip
              link
              fedilink
              English
              arrow-up
              3
              ·
              3 months ago

              bows thank you thank you. Glad about my efforts being well received, and even more so it got you out of bed! Cheers and may your day remain on the up.

        • Logi@lemmy.world
          link
          fedilink
          arrow-up
          3
          ·
          4 months ago

          If you have an actual home key. If it’s ctrl+a or (IIRC, AFK) ctrl+← then we’re even.

          And if we track hand movements then pressing ! twice may be faster than moving to another key.

          But yeah, it’s not at all clear that sudo !! is faster like you’d expect it to be.

      • Nilz@sopuli.xyz
        link
        fedilink
        arrow-up
        2
        ·
        4 months ago

        I use zsh with the sudo plugin. Double tap esc and your current or last command will be prefixed with sudo.

  • Caveman@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    4 months ago

    You can also just do a sudo !! the !! is a shorthand for whatever you tried to run previously.

      • Mountainaire@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        3 months ago

        What is the “fish shell?” Anyway, I’m gonna see if I can actually get this to work in any terminal through an external program…

        • Mountainaire@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          edit-2
          3 months ago

          I figured it out, at least in Linux Mint:

          1. Install Keysharp (which includes installing Microsoft’s .NET 10 Runtime, but not SDK!)
          2. Put this in a .ks folder:

          !s::{ ; Press Alt+S to use sudo on the previous Terminal line
              KeyWait 's'
              If WinActive('ahk_exe gnome-terminal-server')
                  Send 'sudo {!}{!}{Enter}'
          }
          

          Set it as a Startup Program with the command keysharp "(filepath)/(filename).ks" and it’ll always be ready to go!

  • eco_game@discuss.tchncs.de
    link
    fedilink
    arrow-up
    1
    ·
    4 months ago

    On my Terminal that just makes it so I can’t type anymore, I feel like I’m doing something wrong…

    My solution to the problem is CTRL+U, type sudo, CTRL+Y.

      • x0x7@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        3 months ago

        But in almost any shell there is also ctrl+a sudo. ctrl+s requires you haven’t sent it yet.

        Or also up ctrl+a sudo. It’s only one more key press than sudo !!, and unlocks ctrl-a. More useful to teach noobs IMO. Teach a skill instead of a quirk.

    • sem@piefed.blahaj.zone
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 months ago

      I misread this image and have been doing this the past day and it keeps breaking my terminal :(