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)
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.^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
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!
You saying I can just skip cat in that command and it works?
history | grep 'cat'
My output was empty for that command.
Guess why?
Becausehistory
only gives the last few lines in my system.
grep ~/.bash_history
How did I not know this. Thank you!
it’s
grep STRING FILE
to be preciseor
awk '/STRING/′ FILE
if you prefer that for some reason
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.”
also when they see this post
Wow this is really validating for me to read. I’ve been using Linux for a few years but I’m definitely not a computer expert and am intimidated by the command line.
I’ve always felt like googling every command and arrowing up to find an old entry rather than just googling it again marked me as a fake Linux user, not a real one.
Lol don’t feel bad, I can do advanced crazy shit with Linux like pivoting the running OS into RAM so I can unmount the boot drive to do whatever without ever rebooting
But I still [Web Search] commands a shit ton of the time LMAO
You can use Ctrl-R and Ctrl-Shift-R to search through your history instead of having to push up a bajillion times.
Nah, fuck the gatekeepers, you’re all good.
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 has “directory-aware” autocomplete with inlay hints and a fantastic
history
command. I do not suffer from such weaknessSubstring 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!
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.
grep | history [search term]
I think you meant
history | grep [search term]
(which was id 1003 for me btw)
Oops, but yes that’s what I meant.
I do this all the time for that one long command I use monthly like for cert renewals.
alias hf='history|grep'