Now if you had to guess how often I remember that there is a keyboard shortcut that does this, but don't remember what it is, and do remember that I can just press up 30-70 times...
you can hit it again after you are dialed in as much as you want and it will keep going back in time with the words you have in there and stuff that matches!
CTRL+R brings up a prompt and allows you to search through commands you’ve run before. If you’ve run different variations of the command hitting CTRL+R or CTRL+SHIFT+R cycles through commands similar to what you’ve typed out.
This is my approach, and for those who don't know, you can use those line numbers that come back from history to rerun the command. Like if your output is something like this:
$ history | grep tmp
501 ls /tmp
502 history | grep tmp
Wait until you learn about ctrl-R to search the bash history... :) If you press that and start typing, you will get auto complete from previous commands you typed. This is how an experienced linux user can be so fast in the terminal.
There are even better tools for this, so ctrl R is just the built in way. Later you should look into https://github.com/junegunn/fzf
Yeah it's great how ctrl-r is kinda the default instead of something you have to go out of your way to use. Just start typing a command and the up arrow will only cycle through history that matches what you've typed so far.
Idk exactly what plugin it is, but zsh + oh my zsh has exactly this same thing. So hard to live without now that I'm used to it. Probably my favorite feature
Oh is it just a setting then? I remember using plain zsh and it didn't have that functionality until I installed omz, but I could see it being an option that omz enables on install.
Yeah it's great how ctrl-r is kinda the default instead of something you have to go out of your way to use. Just start typing a command and the up arrow will only cycle through history that matches what you've typed so far.
Yeah it's great how ctrl-r is kinda the default instead of something you have to go out of your way to use. Just start typing a command and the up arrow will only cycle through history that matches what you've typed so far.
I rarely use fuzzy finder to search up the commands that I'm going to use. If you realise that a certain command with arguments is often being used, you should create an alias for it so that you don't have need that memory load. That being said, I appreciate shell like fish provides auto complete (derived from command history) to speed up my workload.
85 Comments
HorreC@kbin.social · 56 pts · 3y
control shift R, then start typing, it will search your bash history
LobsterDog@frig.social · 17 pts · 3y
Is it not just Ctrl-R or is that platform dependent
count_duckula@discuss.tchncs.de · 6 pts · 3y
I have always used ctrl-r but I just checked and both work. TIL.
tsukassa@lemmynsfw.com · 3 pts · 3y
Thanks for clearing up this mystery.
mrmanager@lemmy.today · 12 pts · 3y
Hmm, normally it's just ctrl - r... Are you sure the shift is needed on your system?
lungdart@lemmy.ca · 3 pts · 3y
Don't forget fzf. That will really jazz up your history search!
mausy5043@lemmy.world · 1 pts · 3y
No man entry for fzfmrmanager@lemmy.today · 1 pts · 3y
Ok if you want to learn Linux, you need to start web searching for stuff you hear about. :)
lungdart@lemmy.ca · 1 pts · 3y
https://github.com/junegunn/fzf
I recommend installing it as an oh-my-zsh plugin, but it's not hard to get running in vanilla zsh/bash
HorreC@kbin.social · 2 pts · 3y
you are right, I must have just learned it with a shift for some dumb reason and it stuck, thank you internet person.
med@sh.itjust.works · 1 pts · 3y
Some variants have ctrl+r bound to something else
whofearsthenight@kbin.social · 7 pts · 3y
Now if you had to guess how often I remember that there is a keyboard shortcut that does this, but don't remember what it is, and do remember that I can just press up 30-70 times...
HorreC@kbin.social · 3 pts · 3y
you can hit it again after you are dialed in as much as you want and it will keep going back in time with the words you have in there and stuff that matches!
rikudou@lemmings.world · 5 pts · 3y
I recommend using mcfly for that, it makes it even better.
fuckstick@lemmy.world · 4 pts · 3y
This. It took a while for it to sink in but now it’s muscle memory and a huge time saver
Bipta@kbin.social · 3 pts · 3y
What now? What is r? How does this work?
fuckstick@lemmy.world · 6 pts · 3y
CTRL+R brings up a prompt and allows you to search through commands you’ve run before. If you’ve run different variations of the command hitting CTRL+R or CTRL+SHIFT+R cycles through commands similar to what you’ve typed out.
gaiussabinus@lemmy.world · 8 pts · 3y
I'm new to linux and i've been using $history | grep . This information is very useful, thank you.
fuckstick@lemmy.world · 4 pts · 3y
Sure thing! There’s lots of ways to do the same things, but either way stops you from hitting the up key a bajillion times
DontRedditMyLemmy@lemmy.world · 3 pts · 3y
Why r? Maybe if I knew why r, then I wouldn't forget this every 13 seconds...
danielton@lemmy.world · 10 pts · 3y
m15otw@feddit.uk · 52 pts · 3y
Ctrl+R
Then type any part of the command (filename, search string, etc)
Ctrl+R again to cycle through the matches.
(Best feature in bash)
p0q@sh.itjust.works · 12 pts · 3y
Use fzf for a more visual search.
LeanFemurs@lemmy.world · 5 pts · 3y
This is the way.
brakenium@lemm.ee · 8 pts · 3y
I've been using this for a long time, never knew I could press Ctrl + R again. Thanks!
wandering_nomad@lemmy.world · 8 pts · 3y
Ctrl + S to go the other way if you overshoot!
spoopyking@lemmy.fmhy.ml · 6 pts · 3y
Or
history | grep 'command'm15otw@feddit.uk · 3 pts · 3y
Can't just hit enter to run the one you want then, though.
rufus@lemmy.world · 7 pts · 3y
Type: !1234 ... to run whatever history number of the command.
Sidewayspeach@feddit.nl · 1 pts · 3y
But how to go backwards and forwards through the results? I just cycle through again!!
m15otw@feddit.uk · 1 pts · 3y
As @wandering_nomad@lemmy.world said above, Ctrl+S
Sorse@discuss.tchncs.de · 1 pts · 1y
Also works in fish
LucidDaemon@lemmy.world · 1 pts · 3y
Wish I knew this sooner.
runswithjedi@lemmy.world · 12 pts · 3y
Skyler@kbin.social · 7 pts · 3y
This is my approach, and for those who don't know, you can use those line numbers that come back from
historyto rerun the command. Like if your output is something like this:You can run
!501and it will just re-runls /tmpIthronMorn@sh.itjust.works · 1 pts · 3y
Woah! I had no clue!
pleb@discuss.tchncs.de · 6 pts · 3y
Yall are missing out on autocomplete.
runswithjedi@lemmy.world · 2 pts · 3y
bustrpoindextr@lemmy.world · 6 pts · 3y
I got that as
hgreprunswithjedi@lemmy.world · 2 pts · 3y
notasandwich1948@sh.itjust.works · 3 pts · 3y
didn't know there was a comment for that, I just always used cat to read the bash history file
mrmanager@lemmy.today · 2 pts · 3y
Wait until you learn about ctrl-R to search the bash history... :) If you press that and start typing, you will get auto complete from previous commands you typed. This is how an experienced linux user can be so fast in the terminal.
There are even better tools for this, so ctrl R is just the built in way. Later you should look into https://github.com/junegunn/fzf
runswithjedi@lemmy.world · 1 pts · 3y
rocket@wirebase.org · 11 pts · 3y
ttk@feddit.de · 10 pts · 3y
fzf masterrace
tobier@lemmy.world · 10 pts · 3y
This is why I switched to fish; it seems to be much smarter understanding what I want to type.
amos@lemmy.world · 7 pts · 3y
Yeah it's great how ctrl-r is kinda the default instead of something you have to go out of your way to use. Just start typing a command and the up arrow will only cycle through history that matches what you've typed so far.
sneeple@reddthat.com · 2 pts · 3y
Idk exactly what plugin it is, but zsh + oh my zsh has exactly this same thing. So hard to live without now that I'm used to it. Probably my favorite feature
notavote@lemmy.world · 2 pts · 3y
That is default zsh history search, pretty nice.
sneeple@reddthat.com · 1 pts · 3y
Oh is it just a setting then? I remember using plain zsh and it didn't have that functionality until I installed omz, but I could see it being an option that omz enables on install.
notavote@lemmy.world · 1 pts · 3y
I think that it is.
amos@lemmy.world · 0 pts · 3y
Yeah it's great how ctrl-r is kinda the default instead of something you have to go out of your way to use. Just start typing a command and the up arrow will only cycle through history that matches what you've typed so far.
amos@lemmy.world · 0 pts · 3y
Yeah it's great how ctrl-r is kinda the default instead of something you have to go out of your way to use. Just start typing a command and the up arrow will only cycle through history that matches what you've typed so far.
vimdiesel@lemmy.world · 10 pts · 3y
⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬇️ ⬇️
skomposzczet@vlemmy.net · 10 pts · 3y
up, up, up, up, up, cd .., ah there it is.
Aceticon@lemmy.world · 8 pts · 3y
It's like the bus-stop-paradigm: If I wait just a bit longer and it will come. Meanwhile it would've been faster to walk.
Badland9085@lemm.ee · 7 pts · 3y
To anyone who uses vim mode,
?lets you search through your stored command history, from normal mode ofc.Sketchpad01@lemmy.world · 7 pts · 3y
Using the history command just to find the specific IP I need to ssh to
driving_crooner@lemmy.eco.br · 1 pts · 3y
More like to find ping -O 8.8.8.8
Ignacio@kbin.social · 7 pts · 3y
It's even faster if you look for it inside .bash_history.
Teeetris@feddit.nl · 2 pts · 3y
Still noup
Socsa@sh.itjust.works · 5 pts · 3y
We will history | grep docker until morale improves
JasonDJ@vlemmy.net · 4 pts · 3y
Gah it's all
docker container ps -a. OK, fine,history | grep "docker run".Next time I'll put a file in the project directory that tells me how I ran it and .gitignore it. I promise. Next time.
Astaroth@lemmy.world · 5 pts · 3y
pleb@discuss.tchncs.de · 2 pts · 3y
Same. Look at all these people using grep to search their history.
corytheboyd@kbin.social · 5 pts · 3y
https://github.com/junegunn/fzf
Ephur@lemmy.world · 5 pts · 3y
I create so many aliases with the notion of how much time I’ll save… never use ‘em. Works out okay though because a much richer history to fzf through
konakona@sh.itjust.works · 5 pts · 3y
"python3 -m http.server"
titey@programming.dev · 4 pts · 3y
This is the way!
MavTheHack@lemmy.fmhy.ml · 4 pts · 3y
I just use the 'fuck' command after lazily typing letters that somewhat match the command I want to run
brutalbeard@geddit.social · 4 pts · 3y
history | grep {search term}
billygoat@lemmy.fmhy.ml · 3 pts · 3y
I’ve always used set -o vi. Let’s you use vi commands on the bash prompt.
LandedGentryOnlyClub@lemmy.fmhy.ml · 3 pts · 3y
Yeah but last time I typed it, it worked. Who knows what ridiculous typos I'd make right now?
desmosthenes@lemmy.world · 3 pts · 3y
https://github.com/marlonrichert/zsh-autocomplete Autocomplete for Zsh
pmarcilus@reddthat.com · 2 pts · 3y
Tfw I rather type it out instead of searching through the history
bastion@lemmy.fmhy.ml · 1 pts · 3y
I use xonsh, which has decent history - start your command, and up arrow cycles through commands stating with what you typed.
There's good stuff and bad stuff about xonsh.
pmarcilus@reddthat.com · 1 pts · 3y
I rarely use fuzzy finder to search up the commands that I'm going to use. If you realise that a certain command with arguments is often being used, you should create an alias for it so that you don't have need that memory load. That being said, I appreciate shell like fish provides auto complete (derived from command history) to speed up my workload.
watson387@sopuli.xyz · 2 pts · 3y
Oh shit I definitely do this XD
noduh@sh.itjust.works · 2 pts · 3y
I just manage to forget what to type and I'm too lazy to look it up. that and I'm lazy
DumBirb@kbin.social · 2 pts · 3y
It's not about the keystrokes. It's the principle!
737@lemmy.blahaj.zone · 1 pts · 2y
Skooshjones@vlemmy.net · 1 pts · 3y
Lol stop attacking me! 😭
desmosthenes@lemmy.world · 1 pts · 3y
old habits die hard autocomplete for your shell is so clutch though
kaffiene@lemmy.world · 1 pts · 3y
I feel seen.
0x4E4F@sh.itjust.works · 1 pts · 3y
Ctrl + R to search in command history 👍.
original2@lemmy.world · 1 pts · 3y
poweroff
MinusPi@pawb.social · 0 pts · 3y
up up up up up up up up oh wait down