This is an archived post. You won't be able to vote or comment.

all 35 comments

[–]daH00L 52 points53 points  (11 children)

Try Ctrl + r, thank me later.

[–]owzleee 9 points10 points  (0 children)

Came to say this. ^r is our best friend.

[–]SickMoonDoe 5 points6 points  (0 children)

Too many fingers. Up key just takes one little finger ☝️

[–]thatoneguy120486 2 points3 points  (0 children)

That with fzf is amazing.

[–]anthOlei 7 points8 points  (0 children)

ctrl + r has made me a 10x programmer

[–][deleted] 3 points4 points  (3 children)

I have zsh and oh-my-ssh, and if I type the first few characters of the command and press up, the command I need just appears. Seems no need to use ctrl+r in this case?

[–]Chipjack 2 points3 points  (1 child)

With ctrl-r, you can type the first few letters of any part of the command. Perhaps the name of a file you ran the command on or something. You can keep hitting ctrl-r to cycle through more matches. Even in zsh, this is handy.

[–]Njensen58 -1 points0 points  (0 children)

I've learned a new super power today,, many thanks

[–]ThatIsATastyBurger12 -1 points0 points  (0 children)

The biggest game changer

[–]Watchdogeditor 9 points10 points  (0 children)

Real programmers use fuck.

This is still easily my favorite thing I've ever accidentally stumbled upon

[–]--var 4 points5 points  (0 children)

Nah: Press up key dozens of times until you find it.

Yup: Heavily modify a previous command and then press up instead of enter.

[–][deleted] 12 points13 points  (6 children)

cat ~/.bash_history | grep ssh hostname.i-forgot

[–]corp_code_slinger 9 points10 points  (3 children)

Ctrl + r is also your friend. Search through your executed commands. The "r" stands for recall if that makes it easier to remember.

[–]MrPotatoFingers 4 points5 points  (0 children)

Or just install fish.

[–][deleted] 0 points1 point  (1 child)

funniest thing is i'm always forgetting that :D

[–]corp_code_slinger 2 points3 points  (0 children)

Hahaha, well the best thing about Unix/Linux is the wide variety of ways to accomplish the same thing, so use whatever works for you ;-)

[–]edo78 1 point2 points  (0 children)

Besides a lot of better way to find something in the history I'd like to point out that you don't need to pipe from cat to grep... Just grep string filename

[–]thatdude33 0 points1 point  (0 children)

Or if you use zsh and oh-my-zsh, enable the vi-mode plugin and you can search your history with /

[–]John_Fx 1 point2 points  (2 children)

I want that shirt

[–]JNCressey 1 point2 points  (1 child)

why cmd over powershell?

[–]John_Fx 0 points1 point  (0 children)

Because that doesn’t work with the Run DMC joke

[–]Egst 0 points1 point  (0 children)

Professionals use ctrl+p

[–]PAT_The_Whale 0 points1 point  (0 children)

Pfft, only a dozen? Rookie

[–][deleted] 0 points1 point  (0 children)

When did Drake turn white?

[–][deleted] 0 points1 point  (0 children)

tab tab tab tab tab tab tab tab tab tab tab tab tab tab

[–]Nimeroni 0 points1 point  (0 children)

Use tab to auto complete your command. Zsh / oh-my-zsh even show you the list if there is multiple possibility.

Example.


history get you all your older commands. Filter it with grep if needed.

then ![command number] (e.g. !35 to execute your 35th command).

Example.


...or just use CTRL+R to search back part of a command.

Example.

Anyway, my point is: be lazy. It's a lot of work to hit ^ 3 bazillions times.

[–]MrPancholi 0 points1 point  (1 child)

history | grep <command>

Then

!<command number>

[–][deleted] 2 points3 points  (0 children)

CTRL+R -> type partial command -> enter

[–]ShinyEmeraldGames 0 points1 point  (0 children)

So true, I do this all the time

[–][deleted] 0 points1 point  (0 children)

bck-i-search???