You can also just do a
sudo !!the!!is a shorthand for whatever you tried to run previously.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.
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
Does your keyboard not have a home key?
Didn’t know home key could do that lol.
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.
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
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.
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 used to have an alias ‘please’ for that.
Lmao
Wait… YOU CAN DO THAT?!
Forgot to mention but only in fish shell.
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!
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…
Or press Ctrl-S and take a nice walk outside
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
x👏off👏… x👏on👏… x👏off👏, x👏on👏…flowcontrol.
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…
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
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.
<Esc> k I sudo <Space> <Enter>Cannot find any reference online. What is this supposed to do? Not at a PC right now.
!! 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.
It runs the previous command with sudo, also its only for fish shell.
lol no vi mode
Vi mode?
GNU readline is the library that powers features like Ctrl-A, Ctrl-R and Alt+S. By default, it is in emacs mode - that is why it supports these shortcuts, they are the same as in emacs. It also supports vi style editing. You can switch to that by typing
set -o viin your shell. Then you can edit commands as if you were in vi, for example, instead of Ctrl-A you’d do Esc 0. Instead of Ctrl-R you’d do Esc /. If you are fluent in vi then this mode will be more useful.I used to work on really old Unix systems, sometimes over serial connections. They didn’t have bash (only ksh), and they didn’t understand arrow keys. Vi mode was the only way to edit commands that worked reliably.
You can do that??
I always did sudo !!
Well its only for fish shell.
I am using fish shell and just tried it. Thanks man. Such a convenient feature NGL
No problem.
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.
Is this a shell thing or a terminal thing? It doesn’t work for me on
foot.@Dionysus@leminal.space found out that it’s a feature in
fishshell, which I can confirm.Thanks. I think I should check out
fishsoon, I keep seeing it a lot lately and it seems to be made for lazy people like me. :)Fish has a bunch or weirdness if you’re used to other shells for things like substitution, and shortcuts like $_ don’t work afaik.
Huh, I checked and noticed that
fishis non-POSIX. I guess I’ll just stick tozshbut I still want to checkfishto see what’s all this about.Yeah, I tried it for a bit. It gives you coloured autocompletes for things in your history but you accept them with right-arrow rather than tab as well, which is a weird choice, and ctrl-r is still faster. It’s very much a day-to-day user’s experience rather than a scripting shell, I think people stick with others in their shebangs.
Ig its for fish shell
Not sure, I assumed universal because you use it with your history. Type history, see the number next to the command, do a !nnn and it will run that command from history
Oh,
!!definitely works. I meant Alt+S shortcut.Oh, LOL
deleted by creator
Why do you not press the up arrow + Pos1?
What is Pos1?
home key
Fuckit should be able to catch that












