this post was submitted on 16 Aug 2024
570 points (98.3% liked)

Programmer Humor

41078 readers
289 users here now

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

Rules:

founded 6 years ago
MODERATORS
 
top 37 comments
sorted by: hot top controversial new old
[–] SHOW_ME_YOUR_ASSHOLE@lemm.ee 62 points 2 years ago (3 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.

[–] lord_ryvan@ttrpg.network 43 points 2 years 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.

[–] SHOW_ME_YOUR_ASSHOLE@lemm.ee 8 points 2 years ago (1 children)

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

[–] vort3@lemmy.ml 18 points 2 years 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.

[–] lord_ryvan@ttrpg.network 11 points 2 years ago (2 children)

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

[–] vort3@lemmy.ml 4 points 2 years 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.

[–] lord_ryvan@ttrpg.network 2 points 2 years 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!

[–] tetris11@lemmy.ml 1 points 2 years ago (2 children)

I've never understood prompt decoration like this.

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

[–] lord_ryvan@ttrpg.network 2 points 2 years 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.

[–] ikidd@lemmy.world 2 points 2 years ago

It makes my eyes bleed.

[–] theherk@lemmy.world 4 points 2 years ago (1 children)
[–] LiveLM@lemmy.zip 3 points 2 years ago* (last edited 2 years 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

[–] theherk@lemmy.world 3 points 2 years 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.

[–] HereIAm@lemmy.world 7 points 2 years ago (2 children)

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

[–] SHOW_ME_YOUR_ASSHOLE@lemm.ee 4 points 2 years ago

This is too accurate!

[–] dubyakay@lemmy.ca 2 points 2 years ago (1 children)

Can you change the history list size?

[–] embed_me@programming.dev 2 points 2 years ago* (last edited 2 years ago)

Can you configure it to ignore ls and cd ..

[–] insufferableninja 1 points 2 years ago

ctrl+r to do a reverse search of the history instead

[–] muntedcrocodile@lemm.ee 15 points 2 years ago (4 children)

May i introduce u to atuin

[–] slampisko@lemmy.world 34 points 2 years ago (1 children)

I think you mean Crtl+R in bash

[–] henfredemars@infosec.pub 1 points 2 years ago (1 children)

What does this sometimes appear not to work for me even though the command is clearly in the history?

[–] Grappling7155@lemmy.ca 11 points 2 years ago (1 children)
[–] lord_ryvan@ttrpg.network 3 points 2 years ago

Ooh that's even cooler!

Not MySQL, though, but nice for usage in a terminal!

[–] justcallmelarry@lemmy.dbzer0.com 11 points 2 years ago

Nah thanks, up arrow hasnt failed me yet

[–] xmunk@sh.itjust.works 6 points 2 years ago (1 children)

I don't believe in A'tuin. The world is obviously carried on the back of a badger.

[–] MyNameIsRichard@lemmy.ml 3 points 2 years ago (1 children)
[–] xmunk@sh.itjust.works 3 points 2 years ago

And the honey badger mauls. My planet could beat up your planet in a fight.

[–] savedbythezsh@sh.itjust.works 2 points 2 years ago (2 children)

Have you used fish? The built-in fuzzy matching works pretty well for me. Wondering if there's any reason to add atuin in. Sync seems like a negative to me more than a positive.

[–] theherk@lemmy.world 1 points 2 years ago

I use fish with atuin but without sync. It is nice because I can search commands for a given workspace. For example the commands within a given git repository.

[–] muntedcrocodile@lemm.ee 1 points 2 years ago

Yeah they are compatible. Sync can be disabled entirely or self hosted.

[–] Dirk@lemmy.ml 12 points 2 years ago

*tap*
no
*tap*
no
*tap*
no

Okay, NOW it's getting personal!

[–] thr0w4w4y2@sh.itjust.works 9 points 2 years ago

me typing “sudo !!” instead of rewriting the shell command undoes this.

[–] PeriodicallyPedantic@lemmy.ca 2 points 2 years ago

Me in the bash terminal

[–] livingcoder@programming.dev 2 points 2 years ago (2 children)

Who is writing SQL in the terminal?

[–] ikidd@lemmy.world 4 points 2 years ago* (last edited 2 years ago)

MariaDB CLI about once in a blue moon when I have to clear some table that's gotten borked.

[–] Razzazzika@lemm.ee 1 points 2 years ago (1 children)

Was thinking the same thing... now, searching through all my SQL scripts for the past year to find the same logic I want to replicate in another script, well that's different.

[–] livingcoder@programming.dev 1 points 2 years ago

I save "template" SQL queries in a special directory so that I don't have to google how to do specific things. It's basically my own personal "examples" folder.