Ctrl R
holy fucking shit 🤌💪🤯❤️💯
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.
Not if you have fzf you don’t: https://github.com/junegunn/fzf
Like an interactive fuzzy finding history. It’s sick.
So how well you know which command it is of you won’t recognize it when you see it…
…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
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 can’t even keep apart ls and cd it seems.
The number of people who don’t reverse-I-search is too damn high
CTRL+R for those unitiated
reverse-i-search + fzf = <3
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.
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 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.
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.”
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 <archive-name>
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 doesi just use unar (unarchive) nowadays, since that works with all file formats iirc
Extract a tarball with verbose output from the specified file.
And learn how to use the ‘z’ option
You don’t even need the hyphen!
Mind = blown.
tar --help
tar - h
Unfortunately that’s not valid.
$ tar -h tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options Try 'tar --help' or 'tar --usage' for more information.
From man-page:
-h, --dereference follow symlinks; archive and dump the files they point to
Damn.
Thanks, we all died.
:)
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 “! <index number>”, then <enter>.
That’s way more mental effort than pressing up a bunch of times.
or Ctrl+R then search? I don’t know why some people still bother with
history
tbh.Because you can pipe history to grep.
with fzf you get better grep with fuzzy search
This is going to save me so much time pressing the up arrow.
Ctrl-R if you know part of the command.
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.
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
You have to be a linux user to use the console now?