control shift R, then start typing, it will search your bash history
Hmm, normally it’s just ctrl - r… Are you sure the shift is needed on your system?
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…
This. It took a while for it to sink in but now it’s muscle memory and a huge time saver
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.
Why r? Maybe if I knew why r, then I wouldn’t forget this every 13 seconds…
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)
I’ve been using this for a long time, never knew I could press Ctrl + R again. Thanks!
But how to go backwards and forwards through the results? I just cycle through again!!
As @wandering_nomad@lemmy.world said above, Ctrl+S
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
You can run !501
and it will just re-run ls /tmp
didn’t know there was a comment for that, I just always used cat to read the bash history file
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
⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬇️ ⬇️