I've been using ctrl + R
more now :3.. though I definitely used to ↑↑↑↑↑↑↑
Programmer Humor
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
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
check out fzf (install fzf and add (assuming bash) eval "$(fzf --bash)"
to your .bashrc)
Makes ctrl+r a superpower
Ctrl + r with fzf and you’ll never go back.
Woah Ctrl R looks super cool, never knew that I could do that before…
...until you press up one too many times and enter the same command but with a typo. Again.
Been there, done that.
Fish once again undefeated. If I want to find that weird image magick command I used earlier with foo.png in it I just type foo.png
, hit up and its usually the first one. It doesnt matter where foo.png occurs in the command, fish will find it.
The number of people who don’t reverse-I-search is too damn high
^r
Ctrl-r, l ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r. To get ls.
I typed it once, I'm not typing it again
I’ve probably done that for ls
taptaptaptap.... taptaptaptap.... taptaptaptap taptaptaptap taptaptaptap
.... taptaptaptap
... tap ...
... shit I was on a different user when I typed it.
Relevant xkcd: https://xkcd.com/1168/
tar -jcvf archive.tbz ~/stuff/*
Of course I don't know the bomb had bzip2 on it.. I wonder if we can start with ls to see if there's anything to tar or untar
tar -xvf
but only because I had to look it up twice so now my brain has committed it to memory
I don't even know what it does
tar --help
O(n) access, very efficient.
No, I do not care to share the value of n
Or, just type the command “history”, find the index number of the desired command, then type “! ”, then .
That's way more mental effort than pressing up a bunch of times.
https://github.com/atuinsh/atuin is a great tool to manage and search your shell history. I especially enjoy it being able to search commands based on the working directory I was in when I ran them.
It also has more features (which I don't use) to manage dotfiles and sync shell history across hosts/devices.
You have to be a linux user to use the console now?
cat ~/.bash_history | grep
Useless use of cat?
Yes, it was meant to be a self deprecating admission that I have used this unnecessarily verbose command.
Ah. Well. I can not be blameless on this. I also probably use cat unnecessarily still. But less so with grep these days. I'm getting better... I swear!
- zsh-autosuggestions
history | fzf
alias cat="bat --plain --theme=gruvbox-dark"
Aliasing cat
or any other ubiquitous shell utility to a replacement is a mistake. Garuda did this, and it was driving me crazy why cat
was giving me errors. Turns out that they had aliased bat
to cat
, and since bat
is a different program, it didn't work in exactly the same way, and an update had introduced some unexpected behavior.
Drop-in replacements are dumb. Just learn to use a different command.
I think it's ok to add this in a personal .zshrc
, not on a distro level:
If it breaks something - I'd probably know why and can easily fix it by removing alias/calling cat directly.
Also, scripts almost always use bash or sh in shebang, not zsh. So it only triggers if I type cat
in terminal.
It's better to learn the new command, then it still works when you use a different machine that doesn't have your alias
If you are me, there is no brain space for remembering new commands. I can already barely hold on to few dozens that I use often. And occasionally when I need "that one that does that niche thing... how was it?" program - I just sit there sifting through logs for couple minutes.
Today it was od
(tbh it's od
almost half the time; not really the best name to memorize (I really need to make a note or something, so I stop forgetting it, lol))
Also, for this reason I went to great lengths to keep my ~/.zsh_history
protected from being randomly deleted/overwritten by mistake, as it happened a couple of times. Currently it's sitting at around 30_000 lines, oldest command is 2 years old.
Also, even zsh scripts don't read your .zshrc by default.
In fish
, you can enter part of the command, and then press up to search for it. It's kinda awesome.
That's what I do in bash except for pressing up it's ctrl+r. FZF does the fuzzy finding for me. It's so convenient.