this post was submitted on 16 Aug 2024
383 points (96.1% liked)

Programmer Humor

25726 readers
1287 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
top 33 comments
sorted by: hot top controversial new old
[–] superkret@feddit.org 52 points 1 year ago (1 children)
[–] Fillicia@sh.itjust.works 36 points 1 year ago (7 children)

I really like this comic. Just in case someone didn't know in Linux you can:

-Ctrl + r to search previous commands

Or

-type history and precede the command number by an exclamation (!) to repeat the command (I.e. "!13")

[–] Aurenkin@sh.itjust.works 21 points 1 year ago* (last edited 1 year ago) (1 children)

Or just !! for the last command. Particularly helpful if you forgot to prefix it with sudo you can run sudo !!

[–] Redderthanmisty@lemmygrad.ml 2 points 1 year ago

Learn something new everyday

[–] vvv@programming.dev 8 points 1 year ago

I highly recommend installing fzf, and its shell integration. Makes your Ctrl + r magnitudes more pleasant to use!

[–] BlackPenguins@lemmy.world 7 points 1 year ago (1 children)

What. Da fuck. This always existed?!

[–] Trashboat@lemmy.blahaj.zone 8 points 1 year ago (1 children)

It’s probably from within the last 30 years or so

[–] BlackPenguins@lemmy.world 6 points 1 year ago

Oh good as long as it's only a recent update.

[–] Tetsuo@jlai.lu 6 points 1 year ago

Also if you put "sensitive" information in your history by mistake you can use "history -d <line#>" to remove it.

Unfortunately I had to use this command too many times.

[–] zarkanian@sh.itjust.works 5 points 1 year ago (1 children)

Fish shell does this automatically. It's one of the reasons I love it. You can auto-complete based on your command history.

[–] Fillicia@sh.itjust.works 4 points 1 year ago

I'm personlly a zsh+oh-my-zsh person which has the same type of auto complete option.

My only regret is that something broke the thefuck plugin on my pc and now swearing at my screen doesn't fix my mistakes.

[–] oxomoxo@lemmy.world 4 points 1 year ago

This works in Powershell as well, even on Windows...

[–] fmstrat@lemmy.nowsci.com 4 points 1 year ago

Or control R, start typing a bit, control r again.

[–] dejected_warp_core@lemmy.world 9 points 1 year ago (1 children)

There is an advantage to this approach though: fewer errors. You're plucking a known working command from a list instead of manually typing a (possibly) broken version of it. Worse yet is when it's a command where typematic mistakes cause unintended side effects like data loss. So, mashing up 100 times can be pretty smart, especially if you're not a great typist.

[–] benjaminV@piaille.fr 7 points 1 year ago (1 children)

@dejected_warp_core That is true if you assume your history contains only working commands...

Oh no, I have to press up 200+ times if we're counting all the detritus and failure in my command history.

[–] xmunk@sh.itjust.works 7 points 1 year ago

Sorry, do you not keep sql scratch files around?

If deving on the cli name and save to separate files your reusable queries...

[–] Aurenkin@sh.itjust.works 5 points 1 year ago

I've been using Atuin on my work computer and found it to be pretty good if you want something a bit fancier than Ctrl + R

[–] Varyk@sh.itjust.works 4 points 1 year ago (2 children)

I definitely do this with terminal commands, because I'm not hunting for whatever the specific command line to animate my gif wallpaper is.

[–] magic_lobster_party@fedia.io 10 points 1 year ago (1 children)

Ctrl + R is a life changer.

[–] Varyk@sh.itjust.works 10 points 1 year ago* (last edited 1 year ago) (1 children)

HOLY SHIT.

hahahaha, thank you. oh my gosh.

This is the most significant terminal hotkey I've learned in months.

♪⁠┌⁠|⁠∵⁠|⁠┘⁠♪

[–] dejected_warp_core@lemmy.world 3 points 1 year ago (1 children)

Upvoted for the dancing and singing emoticon. Nice art.

[–] Varyk@sh.itjust.works 5 points 1 year ago* (last edited 1 year ago)

Thanks, someone told me how to acess the old-school emotiocns recently and i like them.

I Like THEM!

(⁠ノ⁠°⁠_⁠o⁠)⁠ノ⁠⌒⁠┫⁠ ⁠┻⁠ ⁠┣⁠ ⁠┳

[–] fuzzy_feeling@programming.dev 2 points 1 year ago (1 children)

been there, done that.

then i heard about cli snippet manager. now i use qownnotes snippet manager qc. or you might try pet.

[–] Varyk@sh.itjust.works 1 points 1 year ago

did you know about the ctrl+r command so you can search logged commands by keyword!

magic lobster party told me about it and it's amazing!

I had no idea that was a function until now.

[–] billygoat@catata.fish 4 points 1 year ago

Can’t find the info atm but if you setup inputrc to use vim controls you can use the vim search in psql.

[–] Fedegenerate@lemmynsfw.com 4 points 1 year ago

Me looking for apt update && apt upgrade -y

[–] Boomkop3@reddthat.com 3 points 1 year ago

I do that sometimes, lazy as I can be

[–] hex@programming.dev 3 points 1 year ago

At work, was recently working on a script that alters the repo significantly. Every time I tested the script, I used the up arrow to get the git clean and git checkout HEAD -- files commands to reset the repo. I must've used those 100+ times.

[–] Samsy@lemmy.ml 1 points 1 year ago

That's when I realise I need more coffee.

[–] desmosthenes@lemmy.world 1 points 1 year ago

oh the days before fzf

[–] ExtraMedicated@lemmy.world 1 points 1 year ago

I open the text file where my powershell history is stored when the command I want isn't recent enough.