51 points

control shift R, then start typing, it will search your bash history

permalink
report
reply
15 points

Is it not just Ctrl-R or is that platform dependent

permalink
report
parent
reply
5 points

I have always used ctrl-r but I just checked and both work. TIL.

permalink
report
parent
reply
3 points

Thanks for clearing up this mystery.

permalink
report
parent
reply
12 points

Hmm, normally it’s just ctrl - r… Are you sure the shift is needed on your system?

permalink
report
parent
reply
3 points

Don’t forget fzf. That will really jazz up your history search!

permalink
report
parent
reply
1 point

No man entry for fzf

permalink
report
parent
reply
2 points

you are right, I must have just learned it with a shift for some dumb reason and it stuck, thank you internet person.

permalink
report
parent
reply
1 point

Some variants have ctrl+r bound to something else

permalink
report
parent
reply
7 points

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…

permalink
report
parent
reply
3 points

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!

permalink
report
parent
reply
5 points

I recommend using mcfly for that, it makes it even better.

permalink
report
parent
reply
4 points

This. It took a while for it to sink in but now it’s muscle memory and a huge time saver

permalink
report
parent
reply
3 points
*

What now? What is r? How does this work?

permalink
report
parent
reply
6 points

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.

permalink
report
parent
reply
3 points

Why r? Maybe if I knew why r, then I wouldn’t forget this every 13 seconds…

permalink
report
parent
reply
10 points

Reverse search

permalink
report
parent
reply
49 points

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)

permalink
report
reply
12 points

Use fzf for a more visual search.

permalink
report
parent
reply
5 points

This is the way.

permalink
report
parent
reply
8 points

I’ve been using this for a long time, never knew I could press Ctrl + R again. Thanks!

permalink
report
parent
reply
8 points

Ctrl + S to go the other way if you overshoot!

permalink
report
parent
reply
6 points

Or history | grep 'command'

permalink
report
parent
reply
3 points

Can’t just hit enter to run the one you want then, though.

permalink
report
parent
reply
7 points

Type: !1234 … to run whatever history number of the command.

permalink
report
parent
reply
1 point

But how to go backwards and forwards through the results? I just cycle through again!!

permalink
report
parent
reply
1 point

As @wandering_nomad@lemmy.world said above, Ctrl+S

permalink
report
parent
reply
1 point

Wish I knew this sooner.

permalink
report
parent
reply
12 points
Deleted by creator
permalink
report
reply
7 points

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

permalink
report
parent
reply
1 point

Woah! I had no clue!

permalink
report
parent
reply
6 points

I got that as hgrep

permalink
report
parent
reply
2 points
Deleted by creator
permalink
report
parent
reply
6 points

Yall are missing out on autocomplete.

permalink
report
parent
reply
2 points
Deleted by creator
permalink
report
parent
reply
3 points

didn’t know there was a comment for that, I just always used cat to read the bash history file

permalink
report
parent
reply
2 points
*

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

permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
parent
reply
11 points
*
Deleted by creator
permalink
report
reply
10 points

⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬇️ ⬇️

permalink
report
reply

linuxmemes

!linuxmemes@lemmy.world

Create post

Hint: :q!


Sister communities:

Community rules (click to expand)

1. Follow the site-wide rules
2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack members of the community for any reason.
  • Leave remarks of “peasantry” to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • These rules are somewhat loosened when the subject is a public figure. Still, do not attack their person or incite harrassment.
3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn. Even if you watch it on a Linux machine.
4. No recent reposts
  • Everybody uses Arch btw, can’t quit Vim, and wants to interject for a moment. You can stop now.

Please report posts and comments that break these rules!

Community stats

  • 6.5K

    Monthly active users

  • 1.3K

    Posts

  • 71K

    Comments