Noice (lemmy.ml)
submitted 5 months ago by to c/linuxmemes@lemmy.world
 

top 99 comments

sorted by: hot top controversial new old
[–] 139 points 5 months ago (18 children)
  • [–] 32 points 5 months ago (8 children)

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

  • source
  • parent
  • hideshow 8 child comments
  • [–] 57 points 5 months ago* (last edited 5 months ago) (4 children)

    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.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 15 points 5 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.

  • source
  • parent
  • [–] 6 points 5 months ago (2 children)

    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.

    ❀️ 1
  • source
  • parent
  • hideshow 2 child comments
  • [–] 3 points 5 months ago* (1 child)

    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.

    ❀️ 1
  • source
  • parent
  • hideshow 1 child comment
  • [–] 16 points 5 months ago (3 children)

    Ctrl A is easier to reach than the home key

  • source
  • parent
  • hideshow 3 child comments
  • [–] 4 points 5 months ago (2 children)

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

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 5 months ago (1 child)

    Screen must have been written by someone who wasn't familiar with the shell. It's the only logical explanation.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 5 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

  • source
  • parent
  • [–] 69 points 5 months ago (3 children)
  • [–] 38 points 5 months ago (2 children)
  • [–] 132 points 5 months ago* (30 children)

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

  • source
  • hideshow 30 child comments
  • [–] 24 points 5 months ago (13 children)

    Not all shells support that.

    I use fish btw.

  • source
  • parent
  • hideshow 13 child comments
  • [–] 7 points 5 months ago (2 children)

    I don't even know what I use anymore. My distro seems to keep changing it when I reinstall.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 5 months ago (7 children)

    Holy shit I wish fish supported it. I just press up arrow then hold left arrow and manually type sudo. It fucking sucks

  • source
  • parent
  • hideshow 7 child comments
  • [–] 2 points 5 months ago

    I've used it for so many years that it's not an issue anymore. I remember using !! a lot but it was literally just for sudo. Now i either write what I need and do up or write what I need and then press alt+s, which seems even more intuitive now.

  • source
  • parent
  • [–] 4 points 5 months ago* (4 children)

    wish i could alias that

    alias ffs="sudo !!"

  • source
  • parent
  • hideshow 4 child comments
  • [–] [S] 0 points 5 months ago (6 children)
  • [–] 3 points 5 months ago (5 children)

    What shell are you using? In both bash and zsh, !! is a substitute for a previous command

  • source
  • parent
  • hideshow 5 child comments
  • [–] [S] 0 points 5 months ago (4 children)
  • [–] 2 points 5 months ago (3 children)

    Oof. Posix non-compliant stuff always gives me the ick.
    I highly recommend switching to zsh, it can do the same stuff and more, and it is actually a proper terminal. Switching scripts might be a bit complicated if you're deep into it, but it's worth it

  • source
  • parent
  • hideshow 3 child comments
  • [–] [S] 0 points 5 months ago (2 children)

    All I do in terminal is type, I don't know scripting. But I heard a lot of things about zsh.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 18 points 5 months ago (1 child)

    Top text should maybe say copying by, rather than copying then? Since sudo !! will automatically copy the previous command with sudo in front of it, so there's no manual copying involved

  • source
  • hideshow 1 child comment
  • [–] 17 points 5 months ago (2 children)

    I know alt +. inserts the last argument of previous commands. There must be a good list of alt commands somewhere because they're pretty damn useful.

  • source
  • hideshow 2 child comments
  • [–] 14 points 5 months ago (4 children)

    Wait… YOU CAN DO THAT?!

  • source
  • hideshow 4 child comments
  • [–] [S] 6 points 5 months ago (3 children)

    Forgot to mention but only in fish shell.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 5 months ago (1 child)
  • [–] 2 points 5 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!

  • source
  • parent
  • [–] 12 points 5 months ago (1 child)

    Or press Ctrl-S and take a nice walk outside

  • source
  • hideshow 1 child comment
  • [–] 10 points 5 months ago (3 children)
  • [–] 8 points 5 months ago (10 children)

    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.

  • source
  • hideshow 10 child comments
  • [–] 14 points 5 months ago (6 children)

    If you hit ctrl-s, ctrl-q will unfreeze

  • source
  • parent
  • hideshow 6 child comments
  • [–] 6 points 5 months ago (4 children)

    Interesting, why is that? Like what feature is that?

  • source
  • parent
  • hideshow 4 child comments
  • [–] 8 points 5 months ago* (10 children)

    Cannot find any reference online. What is this supposed to do? Not at a PC right now.

  • source
  • hideshow 10 child comments
  • [–] 8 points 5 months ago (8 children)

    !! Just puts in your last typed command. So if you typed rm -rf /etc, you wouldn't have permission. But if you typed in sudo !! Right after, then you're really fucked.

  • source
  • parent
  • hideshow 8 child comments
  • [–] 7 points 5 months ago (2 children)

    Ah I wasn't clear -- those, I knew. It's alt+S I don't know. I'm at my machine now and it doesn't seem to do anything on Pop_OS.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 5 months ago (4 children)

    But if you typed in sudo !! Right after, then you're really fucked.

    Not if you don't type your password.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 3 points 5 months ago (2 children)

    Adding to this, if you notice numbers next to your previous commands when you run history, you can do ! and it will rerun that command. Probably the second cool shell trick I learned back in the olden days or yore (mid-90s?) after ⬆️

  • source
  • parent
  • hideshow 2 child comments
  • [–] 12 points 5 months ago (1 child)

    I used to have an alias 'please' for that.

  • source
  • hideshow 1 child comment
  • [–] 5 points 5 months ago* (1 child)

    <Esc> k I sudo <Space> <Enter>

  • source
  • hideshow 1 child comment
  • [–] 3 points 5 months ago (2 children)

    oh my zsh plugin just let's you press esc twice :3

  • source
  • hideshow 2 child comments
  • load more comments
    view more: next β€Ί