- cross-posted to:
- [email protected]
- cross-posted to:
- [email protected]
Ctrl R
holy fucking shit 🤌💪🤯❤️💯
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.I typed it once, I’m not typing it again
I write part of the command then ctrl+r. Using FZF mind you. Such a great utility.
You have to be a linux user to use the console now?
- 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 whycat
was giving me errors. Turns out that they had aliasedbat
tocat
, and sincebat
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.Also, even zsh scripts don’t read your .zshrc by default.
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’sod
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.
I just use mcfly
Not sure I understand the point of mcfly. zsh and fish have this functionality built in, where pressing Up with a command partially typed will give auto-completions to that partial match.
Yeah. I also use auto-completions for that. McFly does fuzzy finding and because it’s a different separate db, for me it works better across many sessions to find commands I had just recently used in another session.
I feel like there should be a cursed “long way round” for this that involves needlessly copying .bash_history to a “text file”, running it through an asciibetical sorter (for “efficiency”), using sed to null out any command which doesn’t match the search term…
I’ve been using
ctrl + R
more now :3… though I definitely used to ↑↑↑↑↑↑↑Woah Ctrl R looks super cool, never knew that I could do that before…
check out fzf (install fzf and add (assuming bash)
eval "$(fzf --bash)"
to your .bashrc) Makes ctrl+r a superpowerIt’s awesome until you want to put the cursor in a specific spot of a previous command.
$ rm -f delete-me.txt ctrl-r "me", ctrl-b, ctrl-k $ rm -f delete
But I still use fzf because while I used to do the above, fzf offered more advantage that made switching worth it.
I’ll try it if I don’t forget it by the next time I have access to my PC lol :3
Ctrl + r with fzf and you’ll never go back.
or documentation.To use ctrl-r I have to remember something about the command. To use up arrow I just have to know about how many commands ago I used it.
So how well you know which command it is of you won’t recognize it when you see it…
Not if you have fzf you don’t: https://github.com/junegunn/fzf
Like an interactive fuzzy finding history. It’s sick.
I knew there was an
ls
In there somewhere
ctrl + r, l, s
Much faster than simply typing
ls
!Now I don’t have to type that in again. Phew!
ls … enter ↑ enter ↑ enter
You may consider using
watch ls
I do like that, thanks a lot ulterno!
I can’t even keep apart ls and cd it seems.
…until you press up one too many times and enter the same command but with a typo. Again.
There is an option you can set in .zshrc or .bashrc which only includes lines that exit 0 (success)
Infuriatingly that would omit things like unit test runners from the history in case they don’t pass. As a developer I tend to re-run failed commands quite often, not sure how widely that applies, though.
Oh, stuff like
git diff
andgit log
will end up being omitted pretty often.
And a lot of times, the commands that end with piping intoless
Been there, done that.
The number of people who don’t reverse-I-search is too damn high
It was quite a while before I realised that was possible.
Then not long after starting to use it, that I got fed up and just started opening up the history file and searching in it.why not
history | grep -i
and the search term?even if there are several, you can use ! and the command’s line number to run it again
history
is shell dependent.
CTRL+R for those unitiated
reverse-i-search + fzf = <3
^r
and whenever you forget to sudo:
sudo !!
You need this: https://github.com/nvbn/thefuck
Ctrl-r, l ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r. To get ls.
No way! I didn’t know you could cycle through the results like that… awesome!
It’s basically emacs incremental search.
I’ve probably done that for
ls