ctrl + r
gangHoly Crap. I have gotten into the arrow up mode. Then I went to History.
But, but, but ctrl + r. Holy crap.
Thank you kind sir or madam.
If you enjoy that, then let me introduce you you fzf - a fuzzy finder that has support for replacing ctrl + r in shells with fuzzy matching. Among other uses.
https://github.com/junegunn/fzf#key-bindings-for-command-line
Thank you very much.
Man I over use it at work - even when sitting in front of a pwsh prompt
pwsh with nushell is pretty good
You can also install https://github.com/dvorka/hstr to supercharge your
ctrl+r
I can recommend fzf since it also supports searching the current directory
This is it, my first saved comment on lemmy
Is there a MacOS versión of this? Asking for a friend.
It’s the same,
ctrl
+r
. It is a bash/shell thing so works on any os that uses bash or similar shells. Note, it is not the command key, but ctrl, unlike a lot of other shortcuts on macos.deleted by creator
Fish gang arise (no need for ctrl+r, just press up)
And with a fantastic approximation of fzf history searching.
Ctrl R > start typing
You’re welcome to have your life changed
What the actual… Thanks
Bruh. Ctrl-r
For real. Alternatively use alias to reassign a command to something shorter if it’s one you’re always searching for later. I use ‘update’ as an alias for ‘apt update && apt upgrade -y && apt autoremove && apt autoclean’
Very handy, thank you.
you’re amazing, this is going to change how I use fish
Or the history substring search plugin for zsh showing inline history as you type, like fish.
Y’all know about ctrl-r to search history, right? I went for so many years without even thinking to look for something better than up-arrow, so I have to mention it.
Wait until they learn that you can
ctrl+u
when you mistyped your password insudo
instead of spamming backspace…What does that do?
Delete until start of line. So essentially equivalent to spamming backspace a bunch.
It deletes all keystrokes that have been entered. So, if you know you made a typo when entering your password, you don’t have to press backspace many times to make sure you have deleted all the characters before starting over but you can just press ctrl+u and start over.
ah neat, thanks.
I end up hitting Ctrl+u at work all the time and then being disappointed and holding backspace.
Bro. You just changed my life and don’t even realize it
Here’s another mindfuck: gnu readline is so popular that developers of other software tend to implement its keybinds as hidden features/eastereggs. That’s why ctrl+u works in GTK text input boxes as well!
Damn, that really does solve a lot of problems, lol 😂.
history | grep <search term>
Does the job well if the key combo doesn’t work.
Followed by !xxx where xxx is the number of the command to re-run
This. I didn’t know about CTRL+R, but this has been my goto
Good tip!I didn’t know about that. I just tried it out and it works pretty well but I worry how long it will take to break the habit of mashing the up arrow all the time since I’ve been doing it so long. This is clearly better though.
Finally the
ls
command!Time to up your game with Ctrl + R reverse search! 🤓
Oh, and Ctrl + Shift + R brings you back in the search, niiiiice.
Thank you kind stranger 👍 ☺️.
Look up fzf for luxury treatment
Holy hell this is the best thing since tab autocompletion
And the command is something like
ls -l
👍I see you and I had the same idea. Ha!
I usually use
ls -hal
.ls -lah
is what I do 🙌ls -lah unite
Up up up up up up up up up oh wait down
you allllways overshoot
Based
ctrl + r then enter phrase
With fzf!
I haven’t been on linux in a while but i remember using a file manager that had fuzzy finder and it was nice. I miss linux actually. oh well!
Ctrl+R together with
fzf
makes this obsoletemy humble method: history | grep -i searchterm
Then ![historynumber] to execute it
exactly!
fzf
is pretty cool, but I found its ctrl-r “menu” to be more confusing than the old “one entry at a time” style.(Ofc could be a configuration thing but I’m somewhat an oldhat when it comes to my terminal habits.)
- vim ~/.inputrc
- Paste the following:
"\e[A": history-search-backward "\e[B": history-search-forward
Thank me later
Man, I’ve been on unix systems since, oh, 1994, but I’ve never messed with my .inputrc … may need to take the dive…
Ok this is actually great. Is there a way to make it so when you down arrow again it will clear the cmd line (or take it back to the prefix)?
Like “py” -> up -> down -> result is “py”
Currently it would show my last python command (or whatever matches).
I’ll be a madlad and thank you right here, right now!
Hey! Sorry just getting into Linux, I love learning about cool ways of doing things more efficiently. What does this do exactly? I’ve noticed others mentioning CTRL+R and I am not sure what that means either. Thank you!
Basically, while ctrl+r is nice, this is how I got used to use my system. What this does is enable search for when you press arrow up. If you type nothing then it’s default behavior but if you type “ssh” and then start pressing arrow up it will bring up the previous command that had the word ssh in. It’s worth it for someone who constantly forgets ctrl+r exists
That’s awesome. Thanks for explaining!
I usually do ctrl+r but with zsh I can type the beginning of the command and press up and it will search that way too.
fish automatically searches as you type, just start typing and press -> when you find the command you need.
Zsh does the same, though I think you need oh my zsh and a plugin for it.
~/.bash_history is where my documentation lives
yeah, the other day i was supposed to remove a restriction from a router that was some custom thing built on a raspberry pi. i logged in, started messing around, trying to figure out the system, and of course i looked at bash_history because why not, i’m unfamiliar with the setup so it seemed like a good place to start. up until i found some commands editing it. so i’m like
$ export HISTFILE=/dev/null # alright, two can play this game
it ended up being a simply cron job that runs a script that starts and stops hostapd every once in a while. i didn’t disable the cron job, i just commented out a critical line from the stop script. happy debugging to the sysadmin, lol
I feel this in my soul. Or when you realize you’re hitting up up up up to find something trivial like
ls
and it would have been more efficient to just typels
. LOL.Bro, do you even
^R
?