Ctrl+R
post
I used to be like this but people seriously. CTRL+R
Do it. Don't make this one of those things you've heard about and just never got around to trying. Open your terminal right now and CTRL+R and type any part of the command you did before. If the command you want is not showing first just hit CTRL+R again to go to the next one back.
DO IT.
Edit: I did learn from this thread today though that ZSH has it set to where you can just type part of what you're looking for then hit up to do the same thing. Neat!
You can empower Ctrl+r event more by using fzf. After I started using it, I can't imagine going back to without it.
Holy shit. I just tried it. ctrl+r is a revelation! How the fuck did I not know about this?
WHAT THE FUCJ IS THIS SORCERY BRO I'VE BEEN USING LINUX FOR AGES AND NEVER KNEW THIS BROOOOOOOOOO
If you want to level up ctrl-r, upgrade to Atuin: https://atuin.sh/
Edit: I did learn from this thread today though that ZSH has it set to where you can just type part of what youβre looking for then hit up to do the same thing. Neat!
Fish too, it's fantastic.
CTRL+R + FZF is the goat. You just need to vaguely remember the command and you'll find it.
The worst is when you remember doing something before, but don't remember enough details to be able to effectively search for it.
Although, even then, I'm not going to just mindlessly hit "up". Last time it happened I fed my command history through grep and removed all the things that I knew the command wasn't. Just removing "ls" and "cd" from your history cuts the number of commands down by 80% or something.
Check out the fzf shell bindings. Reverse history search with fuzzy matching is one of the features.
I love this one but is the gif moving at 0.5 frames a second or is it just me
Ctrl + R and start typing the command, it'll come up, press enter. Im just more lazy because I know there are still faster ways.
Edit: instead of hitting enter, keep pressing ctrl + R to cycle through history commands that contain what you typed in
More like β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ mother fucker β¬οΈ
Pretty much, yeah.
Rather than jot down in a text file the various ffmpeg commands I use frequently...
Raktajino@laptop:~/Downloads$ history | grep ffmpeg
12 sudo apt install audacity gimp ffmpeg mplayer
184 history | grep ffmpeg
215 ffmpeg -i source.mkv -ss 629 -t 7 out.mkv
217 ffmpeg -i out.mkv -s 0.5 -vf scale=1280:720 out.mp4
218 ffmpeg -i out.mkv -ss 0.5 -vf scale=1280:720 out.mp4
231 ffmpeg -i out.mp4 -vf "subtitles=out.srt" final.mp4
503 ffmpeg -i toofat.wav toofat.mp3
...
682 history | grep ffmpeg
684 ffmpeg -i 1.gif -i 2.gif -filter_complex "[1:0] [2:0] concat=n=2" out.gif
685 ffmpeg -i 1.gif -i 2.gif -filter_complex "[1:0] [2:0] concat=n=2:v=1" out.gif
686 ffmpeg -i 1.gif -i 2.gif -filter_complex "[1:0] [2:0] concat=n=2:v=1" -map '[v]' out.gif
687 history | grep ffmpeg
688 ffmpeg -i 1.gif -i 2.gif -filter_complex "[0:0] 12:0] concat=n=2:v=1" -map '[v]' out.gif
689 ffmpeg -i 1.gif -i 2.gif -filter_complex "[0:0] 1:0] concat=n=2:v=1" -map '[v]' out.gif
690 ffmpeg -i 1.gif -i 2.gif -filter_complex "[0:0] [1:0] concat=n=2:v=1" -map '[v]' out.gif
691 ffmpeg -i 1.gif -i 2.gif -filter_complex "[0:0] [1:0] concat=n=2" out.gif
694 history | grep ffmpeg
I'm begging you to use CTRL+R
If you have a fzf or other plugin installed, great. the vanilla Ctrl R is kinda mid in most shells IMO
You can also create aliases for frequently used commands. You can even put a function in an alias so it can accept arguments, but it would probably be better to just write a shell script at that point.
You're gonna love once you start
-
tagging your ffmpeg commands like
do a thing # dothingname -
Just
!?dothingnamelater to recall it and run it.
Its a little easier to NOT accidentally !?alt and discover halt is matched first.
I just mapped page-up to search (and you can too)
history | grep βpart of the command I rememberβ
history | grep [the thing]
CTRL+R [the thing]
please i beg you
with grep I see all the alternatives, Ctl+R just shows me one
For me ctrl-r is faster most of the time, history | grep [command] is better if I can't easily pattern match (don't remember it exactly, using several flag variations, etc.). they're both good tools.
You can press up
Ppsshh. Not lazy enough. Create that in a script and call it "hgrep" and drop it into path.
i was doing cat ~/.bash_history | grep thing which is stupid so i started doing grep "thing" ~/.bash_history
now you're telling me i should do history | grep thing
i can't win
Some would call the former command cat abuse.
In short, unless you want the contents of a file printed to stdout (or multiple files concatenated), the command can probably be written without cat, instead using the filename as an argument (grep pattern file) or IO redirection (cmd < file).
Stylistics and readability are another thing though.
Exactly! Now copy paste it into Joplin where you'll never see it ever again.


top 100 comments