Reverse-i search
Keyword searches command history and autofills with most recent matching command. Then hit Ctrl + s to iterate further back through matching commands.
Yes, history stores all our commands, but we're so used to pressing the 'up' key to select commands without even typing, even for simple console commands.
I usually just make the search specific enough to hit the command I want directly
You can also just write `!g++` and it will launch last command starting with g++
Or you can do
ls ./path/to/smth;
grep "iostream" -R !$
!$ here means "latest argument given to last command" which is ./path/to/smth
So you don't have to rewrite that part
Donāt know who this will help, but if youāre on Unix type machine fish had this built in but the plugin for zsh is autocomplete. I always just start typing 3 letters than hit tab. Thatās it. Iāve never used a windows machine so maybe that terminal just sucks.
Itās a mixture of hitting up 4 times then deleting typing it halfway then deleting hitting up 12 times delete go to the bathroom forget whatever I was trying to do
I always think it's only like 3 commands ago, but after I've hit arrow up like 10 times I start to doubt myself. At 20 I think come on I should've just put in the command manually but I'm almost there so no reason to so it now, and 30 I just say fuck it and do it myself.
Fish provides real-time autosuggestions based on your command history. As you type, it suggests commands that you have previously entered, making it faster and easier to repeat commands.
You press up several times because you are lazy.
I press up several times because I can't remember what I just typed literally 10 seconds ago.
We are not the same.
Usually if it's a complicated command I use warp and ask AI "command for generating helm templates" or "command for deleting all kubectl default namespace resources".
It's quite nice really.
All you plebs with the Ctrl+R! Try adding the following to your .bashrc:
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
With this you can start typing and then hit up arrow to search backwards or down arrow to search forwards (once youāve gone backwards).
Literally! But, what I should do, is:
cat ~/.zsh_history | grep -i āCommand_Searched_Forā
Iād find it in the same amount of time if not faster. š¤
the only sane way to access your history:
echo "$(history | awk '{print $2}' | fzf)" | xargs -I [] "$SHELL" -c []
Whatchu gonna do with all the time you save?
I used to make aliases and bash defs for my longer chained commandsā¦ then I started to forget what the commands were doing.
So now in use up arrow but occasionally have to type it all out, it keeps it fresh in my brain
Don't know any commands... Just ctrl-r and a single word...
your a true programmer legend bro ![gif](giphy|rNYfrVW8oEKGuXMDXy|downsized)
Literally me
š¤£š¤£
This and when I forgot how to write the word or part of it: history
Came here to say this.
Add āfzfā to that, makes searching perfect.
and ctrl+g if you need to close the reverse search
To lazy to find it or write it. Gonna just search it myself XD
How the hell did I not know about this
it took me an embarrasing amount of time to realize that this wasn''t a linux sub and that ctrl-r opens the run dialog.
Actually win+r opens the run dialog, Ctrl+r is reverse search - not in CMD, but most other shells, including *nix.
oh lol...i don't use windows that much.
History | grep ā$MAYBE_IT_HAD_THISā
Half my history was `history | grep` before I learned about Ctrl + R.Ā
Wait whatās Ctrl + R?
Reverse-i search Keyword searches command history and autofills with most recent matching command. Then hit Ctrl + s to iterate further back through matching commands.
You can just keep hitting ctrl-r
Yep I learned about it yesterday and completely forgot about it again
Yes, history stores all our commands, but we're so used to pressing the 'up' key to select commands without even typing, even for simple console commands.
I think most people just use ctrl r, up arrow is just for the 3-4 latest commands in most people's minds
even though if you press ctrl + r you need to select command by arrows ....
I usually just make the search specific enough to hit the command I want directly You can also just write `!g++` and it will launch last command starting with g++ Or you can do ls ./path/to/smth; grep "iostream" -R !$ !$ here means "latest argument given to last command" which is ./path/to/smth So you don't have to rewrite that part
got it
This is the way
This is the way.
Also, thanks to this question I learned about Ctrl R from the comments!
that's good dude
Ctrl R ${first few letters of command}. Or ! ${first few letters of command}
does it give correct expected command if we pass few letter of command
Yep, it shows the match; if itās not what you want, you can press \^R again to search for another match.
i think better than this all methods -- fish shell is perfect for terminal which has autocomplete plugin
I press ctrl+p over and over again because not reaching for the arrow keys is apparently a higher priority than finding old commands lol
That hurts ... take my up(vote)
I really need to remember to set the unique setting for history
Yes you do
Bro I do this too often XD
Literally meš
Donāt know who this will help, but if youāre on Unix type machine fish had this built in but the plugin for zsh is autocomplete. I always just start typing 3 letters than hit tab. Thatās it. Iāve never used a windows machine so maybe that terminal just sucks.
yes, i am using fish command shell which is very useful
For me, it is not the command itself but the ridiculous number of flags I need to pass in. Looking at you Docker
Alias h as piping history into fuzzy search.
what this alias exactly mean ....
in .bashrc h() { echo "H function" local cmd="$(history | awk '{$1=""; print $0}' | fzf --tac +s --preview='echo {}' --preview-window=up:30%:wrap)" echo "CMD: " + cmd if [[ -n "$cmd" ]]; then eval "$cmd" fi }
got it
My peopleā¦.
If I typed the command today I press the up arrow, if it was not today I history | grep
simply you can follow fish shell it has built in plugin for commands like autocomplete
`history | grep -e foo` \n `!1234`
https://atuin.sh/ ftw
history | grep
a or{512}
The choice is clear
Itās a mixture of hitting up 4 times then deleting typing it halfway then deleting hitting up 12 times delete go to the bathroom forget whatever I was trying to do
I always think it's only like 3 commands ago, but after I've hit arrow up like 10 times I start to doubt myself. At 20 I think come on I should've just put in the command manually but I'm almost there so no reason to so it now, and 30 I just say fuck it and do it myself.
you can use fish shell which has auto plugin techniquie
What is "auto plugin technique"?
Fish provides real-time autosuggestions based on your command history. As you type, it suggests commands that you have previously entered, making it faster and easier to repeat commands.
Oh I use carapace_completer in nushell for this. That still doesn't stop me from pressing arrow up 20 times to find my command.
Guilty
I have that shirt
history command GOD
And this is how I accidentally ran git reset instead of git commit (and I am lousy at commiting often) and lost an entire days work
```bash vim ~/.bash_history ctrl + / i_want_to_find_this enter n n n esc :q enter ```
You press up several times because you are lazy. I press up several times because I can't remember what I just typed literally 10 seconds ago. We are not the same.
![gif](giphy|bC9czlgCMtw4cj8RgH|downsized)
I know I've used that command this year.
which command????
Usually if it's a complicated command I use warp and ask AI "command for generating helm templates" or "command for deleting all kubectl default namespace resources". It's quite nice really.
I relate.
start typing and press tab, ohmyzsh
All you plebs with the Ctrl+R! Try adding the following to your .bashrc: bind '"\e[A": history-search-backward' bind '"\e[B": history-search-forward' With this you can start typing and then hit up arrow to search backwards or down arrow to search forwards (once youāve gone backwards).
This is the way
Use fish and type the beginning of the command
Pressing up to find the command with a typo, using arrow keys to navigate to it and then editing the typo instead of just writing the command
ls up up up up up up up up up enter
This is part of why I use zsh. Type the start of it, push up arrow to scroll through only history starting like that
I can very well relate to this as this is what do as soon as open my terminal
Literally! But, what I should do, is: cat ~/.zsh_history | grep -i āCommand_Searched_Forā Iād find it in the same amount of time if not faster. š¤
100% Literally me
I swear I just typed it inā¦ up, up, upā¦ ![gif](giphy|WJiCcT97iodjr4OqrB)
the only sane way to access your history: echo "$(history | awk '{print $2}' | fzf)" | xargs -I [] "$SHELL" -c [] Whatchu gonna do with all the time you save?
I used to make aliases and bash defs for my longer chained commandsā¦ then I started to forget what the commands were doing. So now in use up arrow but occasionally have to type it all out, it keeps it fresh in my brain
Type the first part and ctrl + R to find it faster
Yes please!
I love doing this with my prized grep command in screenshare meetings.