50 0 ReplyI really like this comic. Just in case someone didn't know in Linux you can:
-Ctrl + r to search previous commands
Or
-type history and precede the command number by an exclamation (!) to repeat the command (I.e. "!13")
35 0 ReplyOr just
!!
for the last command. Particularly helpful if you forgot to prefix it withsudo
you can runsudo !!
19 0 ReplyI highly recommend installing fzf, and its shell integration. Makes your Ctrl + r magnitudes more pleasant to use!
8 0 ReplyWhat. Da fuck. This always existed?!
7 0 ReplyAlso if you put "sensitive" information in your history by mistake you can use "history -d <line#>" to remove it.
Unfortunately I had to use this command too many times.
6 0 ReplyFish shell does this automatically. It's one of the reasons I love it. You can auto-complete based on your command history.
5 0 ReplyOr control R, start typing a bit, control r again.
4 0 ReplyThis works in Powershell as well, even on Windows...
4 1 ReplyCtrl + r to search previous commands
That's a readline thing by the way, so it doesn't just work in bash but also works with other cli applications that are compiled with readline support, for example
virsh
,psql
,fdisk
, ...1 0 Reply
There is an advantage to this approach though: fewer errors. You're plucking a known working command from a list instead of manually typing a (possibly) broken version of it. Worse yet is when it's a command where typematic mistakes cause unintended side effects like data loss. So, mashing
up
100 times can be pretty smart, especially if you're not a great typist.9 0 Reply@dejected_warp_core That is true if you assume your history contains only working commands...
6 0 ReplyOh no, I have to press
up
200+ times if we're counting all the detritus and failure in my command history.3 0 Reply
Sorry, do you not keep sql scratch files around?
If deving on the cli name and save to separate files your reusable queries...
7 0 ReplyI've been using Atuin on my work computer and found it to be pretty good if you want something a bit fancier than Ctrl + R
5 0 ReplyI definitely do this with terminal commands, because I'm not hunting for whatever the specific command line to animate my gif wallpaper is.
5 0 ReplyCtrl + R is a life changer.
10 0 ReplyHOLY SHIT.
hahahaha, thank you. oh my gosh.
This is the most significant terminal hotkey I've learned in months.
♪┌|∵|┘♪
9 0 Reply
2 0 Replydid you know about the ctrl+r command so you can search logged commands by keyword!
magic lobster party told me about it and it's amazing!
I had no idea that was a function until now.
1 0 Reply
Can’t find the info atm but if you setup inputrc to use vim controls you can use the vim search in psql.
4 0 ReplyMe looking for apt update && apt upgrade -y
4 0 ReplyI do that sometimes, lazy as I can be
3 0 ReplyAt work, was recently working on a script that alters the repo significantly. Every time I tested the script, I used the up arrow to get the
git clean
andgit checkout HEAD -- files
commands to reset the repo. I must've used those 100+ times.3 0 Replyoh the days before fzf
1 0 ReplyI open the text file where my powershell history is stored when the command I want isn't recent enough.
1 0 ReplyThat's when I realise I need more coffee.
1 0 Reply