You can do that??
I always did sudo !!
Well its only for fish shell.
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 unlock ctrl-a. More useful to teach noobs IMO.
I am using fish shell and just tried it. Thanks man. Such a convenient feature NGL
No problem.
Why do you not press the up arrow + Pos1?
What is Pos1?
home key
You can also just do a
sudo !!the!!is a shorthand for whatever you tried to run previously.Bruh

What shell are you using? In both bash and zsh,
!!is a substitute for a previous commandFish
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 itAll I do in terminal is type, I don’t know scripting. But I heard a lot of things about zsh.
Oh-my-zsh is a good start then. It gives you a bunch of themes and presets and plugins so you can do whatever you want with your zsh
I’ll try thanks for the recommendation.
Was about to say, why would you copy anything when using
sudo !!lol… because I had no idea about this until now. Sweet!
Not all shells support that.
I use fish btw.
I made my own !!
I know what you meant (I have one for fish as well), but I chucked because you looked very enthusiastic about it!
The fish function for
!!is super useful though
I don’t even know what I use anymore. My distro seems to keep changing it when I reinstall.
echo $SHELLLol, thanks. Now I know.
Holy shit I wish fish supported it. I just press up arrow then hold left arrow and manually type sudo. It fucking sucks
… are you not aware of Alt+S?!
Nope haha. Thanks for letting me know
I’ve been using this plugin https://github.com/oh-my-fish/plugin-bang-bang fish also allows going through previous arguments with alt+up
Epicc. I should install thjs
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.
Does your keyboard not have a home key?
Didn’t know home key could do that lol.
I learned something new today!
I completely forgot about this one!
wish i could alias that
alias ffs=“sudo !!”
alias ffs='sudo $(history -p !!)'Just to confirm: I tried this, it works.
That doesn’t work? I would have thought it would work.
!! Gets replaced by whatever was run before the alias command

Ayo chill

I approve of the ice to coke ratio. I am now chill.
Good
- ctrl + p
- ctrl + a
- sudo [space]
- enter
How about just one keyboard shortcut and enter.
Always amused me that
sudo !!is actually more keypresses (at least on keyboards where typing!requires holding Shift).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.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.
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.
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.
- Single-Handed Vector String: 40.878 U
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.
But it’s faster since your hand move less and you can keep
shiftpressedI use zsh with the sudo plugin. Double tap
escand your current or last command will be prefixed with sudo.I don’t dabble in black magic. /j
It’s actually pretty neat.
Ctrl A is easier to reach than the home key
Unless you’re in a default screen session (I always thought ^A was such a dumb default for screen to use).
Screen must have been written by someone who wasn’t familiar with the shell. It’s the only logical explanation.
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
alias fuck="sudo !!"Wait, you don’t have The Fuck installed?
Waiting for it to be rewritten in rust
Only worth installing if it is 🔥🔥🔥blazing⚡⚡⚡fast
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
Yeah I remembered that after uploading the meme.
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.
Thanks to you, I just find out new keyboard shortcut
The manual is a good place to start. It’s just GNU Readline under the hood.
Wait… YOU CAN DO THAT?!
Forgot to mention but only in fish shell.
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…
Ah oki lol
I figured it out, at least in Linux Mint:
- Install Keysharp (which includes installing Microsoft’s .NET 10 Runtime, but not SDK!)
- Put this in a
.ksfolder:
!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!
I used to have an alias ‘please’ for that.
Lmao
Or press Ctrl-S and take a nice walk outside
I misread this image and have been doing this the past day and it keeps breaking my terminal :(
sudo !!
For some reason I get this

Use zsh
It works.
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.
If you hit ctrl-s, ctrl-q will unfreeze
Interesting, why is that? Like what feature is that?
Same reason there’s a ScrollLock key on keyboards. Didn’t always have scrollbars and if the application prints more than you can read, you want to pause that…
THAT’S WHAT IT’S FOR??
Now that I think about it, it does seem pretty obvious.
Short answer, terminals are built on the same technology as physical terminals from the 60s and 70s when controlling the flow of data from the server was a more useful feature.
It’s part of the terminal emulator flow control
x👏off👏… x👏on👏… x👏off👏, x👏on👏…flowcontrol.
Ctrl + S freezes your shell yes. But Alt + S?
Ah indeed, ALT+S does nothing. I must have pressed both before realizing it was frozen.
Need to use the fish shell instead of the others for this to work. (May be a way to enable it in other shells but I’m not sure how)
Cannot find any reference online. What is this supposed to do? Not at a PC right now.
It runs the previous command with sudo, also its only for fish shell.
!! 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.
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.
Seem to be a
fishshell thing.I tested on my good ole trusty
bashand got nothing so I went searching.EDIT: Clarification :
alt+sseems to be afishshell thing.Ya I haven’t tried alt s. Never heard of it before either.
But if you typed in sudo !! Right after, then you’re really fucked.
Not if you don’t type your password.
I assume if you are silly enough to type in rm -rf /etc, then you are silly enough to type in your password 😅
Adding to this, if you notice numbers next to your previous commands when you run history, you can do !<number> and it will rerun that command. Probably the second cool shell trick I learned back in the olden days or yore (mid-90s?) after ⬆️
ctrl-r is generally quicker
Learned that one embarrassingly much later.
<Esc> k I sudo <Space> <Enter>oh my zsh plugin just let’s you press esc twice :3
Ayo what, I didn’t know that but I use fish.
i know you dont use it but just in case you were curious; it’s the sudo plugin: https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/sudo/README.md

















