this post was submitted on 16 Aug 2024
598 points (97.9% liked)

Programmer Humor

32032 readers
1245 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 66 points 1 month ago (2 children)

I'm not a programmer but I do this on the Linux command line all the time to find a command I used days or weeks ago. Or I'll spend 20 minutes grepping history instead. All to avoid spending 5 minutes reading the manpage so I can remember which flags and arguments I used.

[–] [email protected] 46 points 1 month ago (2 children)

Perhaps pressing [Ctrl]+[R] and typing to search makes it easier, I mean instead of grepping history?
Most terminal emulators support it.

You can also change your query (backspacing and typing again) and press [Ctrl]+[R] multiple times to go to older matches.

[–] [email protected] 9 points 1 month ago (1 children)

I will have to try that, I didn't know that functionality existed, thanks!

[–] [email protected] 18 points 1 month ago (1 children)

Let me tell you that you can also add comments to your terminal commands and use them to search history using fzf. This might sound confusing but basically you do this:

commandwithweirdoptions --option1=value1 --option2=value2 # run the usual thing

Then you press Ctrl+R and type anything like «the thing», it uses fuzzy matching and finds the command in history, with a menu of other similar commands. Press enter, done.

Note that you need to have fzf installed, otherwise there is no fuzzy matching and no menu of matching history results.

[–] [email protected] 11 points 1 month ago (2 children)

Seems to work with [Ctrl]+[R] as well, though of course only with exact matches.

[–] [email protected] 4 points 1 month ago (1 children)

Sure, just as I said, this would work id you don't need menu or fuzzy matching. But I would recommend using fzf history search anyway, it's just too good.

[–] [email protected] 3 points 1 month ago

M-hm, I will try it as well! I was just letting people know the comment trick works regardless, cause that's a nice tip as well!

[–] [email protected] 1 points 1 month ago (2 children)

I've never understood prompt decoration like this.

How.
Does.
Punctuating.
Every.
Statement.
Increase.
Readability.

[–] [email protected] 2 points 4 weeks ago

It makes my eyes bleed.

[–] [email protected] 2 points 1 month ago

You meant the PS1 prompt?

I just use one of the default oh-my-zsh themes that makes a clear line, so I can easily find the last line above a long output, for example when trying to read it back chronologically. With other PS1's I often scroll over it without noticing.

[–] [email protected] 4 points 1 month ago (1 children)
[–] [email protected] 3 points 1 month ago* (last edited 1 month ago) (1 children)

This looks super neat but I don't really like the idea of sending my shell history to a third party, nor can I host my own server right now.
Wish it was peer-to-peer like Syncthing

[–] [email protected] 3 points 1 month ago

I don’t either, but you don’t have to use that feature. I don’t. I just use with local db for that machine.

[–] [email protected] 7 points 1 month ago (2 children)

And then you realise your dumb endless ls-ing has pushed the command off the history list

[–] [email protected] 4 points 1 month ago

This is too accurate!

[–] [email protected] 2 points 1 month ago (1 children)

Can you change the history list size?

[–] [email protected] 2 points 1 month ago* (last edited 1 month ago)

Can you configure it to ignore ls and cd ..