Ctrl R
…until you press up one too many times and enter the same command but with a typo. Again.
Been there, done that.
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
^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
O(n) access, very efficient.
No, I do not care to share the value of n
taptaptaptap… taptaptaptap… taptaptaptap taptaptaptap taptaptaptap
… taptaptaptap
… tap …
… shit I was on a different user when I typed it.
Or “shit, I did in tmux last time so I could close the terminal window.”
Substring completion on ZSH. Type in a small part of the command you want to find and then press up.
bash supports this feature too btw
Added to my mental toolbox, thanks!
fish has “directory-aware” autocomplete with inlay hints and a fantastic
history
command. I do not suffer from such weaknessOr, just type the command “history”, find the index number of the desired command, then type “! <index number>”, then <enter>.
or Ctrl+R then search? I don’t know why people bother with
history
tbh.Because you can pipe history to grep.
with fzf you get better grep with fuzzy search
Holy cow!! I didn’t know that. I have been using history > history.txt to find “that one command for that one thing” I only need once every other month or so. Thanks, now I can just do that.
also when they see this post
Relevant xkcd: https://xkcd.com/1168/
tar --help
In
fish
, you can enter part of the command, and then press up to search for it. It’s kinda awesome.yeah I ONLY just recently switched to fish after using zsh and oh my zsh for so long - pretty much since first starting linux cause I once saw someone using it on unixporn and I thought “that’s cool”
when I switched to NixOS zsh with all the plugins was a total slog. switched to fish and it just HAS everything that zsh/oh my zsh and the various plugins had but baked in.
so yeah in Fish it’s just starting to type something and hoping it’s still in the history.
Too many people still use Bash.
I like zsh on mac because pretty colors
Too many distributions still ship with Bash.
In the real world, the only thing better than perfect is standardized.
Yeah, true. But, it’s easy to change.
Bash is the Internet Explorer of shells. It’s great for installing a more useful shell.
That’s super unkind and incorrect. IE was a trash software that was widely available because MS was trying to extend their monopoly into new areas.
Even if it’s not your taste, bash is a mature, stable FLOSS package with wide community support. The reason it is so common is due to it’s positive attributes, not because there is a plot to make it the only choice available to you.
Bash might be better than IE. But I think we can agree that it is no longer a good shell.
Its syntax is awful, and lacks many features that other shells have.
It is only so widely used because it is a de facto standard. If bash was created today, barely no one would us it.
That’s not true. Internet Explorer was fucking useless for scripting together things, unlike bash.
Internet Explorer shell expansion always trips me up.
What shell do you recommend?
I like zsh, but some people say great things about fish.
My problem with those is bash is always there and just works.
Yes, just like Internet Explorer.
It’s good to know how to do things in bash, since you’re going to encounter it pretty often. But, that doesn’t mean you shouldn’t customize your shell on the machine(s) you use most often. Why stick with the default when there are better options? You’re just hobbling yourself.
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 always go past it because I go way to fast.
I have more then once gave up on pressing up, hit ctrl + c to reset only to see the command I wanted briefly flash up as I am hitting ctrl + c