Just discovered how easy it is to recall my last arg in shell and my brain went 🤯 How come I’ve never learned about this before!? I wonder how many other QOL shortcuts I’m missing on 🥲
@aelaraji@aelaraji.com You mean Control R?
@prologic@twtxt.net no, good man. Follow the link, follow eet! :-)
@aelaraji@aelaraji.com Oh, that’s great! I haven’t heard about any of them before either. There’s also a caveat though, that I ran right into the very first time I tried this in zsh:
$ ls > /dev/null
$ echo $_
--color=tty
Yeah, exactly what you think:
$ which ls
ls: aliased to ls --color=tty
Alt+.
is going to be my favorite one! In the above, it would also give me /dev/null
, which might be probably more what I would expect.
@aelaraji@aelaraji.com I use Alt+.
all the time, it’s great. 👌
FWIW, another thing I often use is !!
to recall the entire previous command line:
$ find -iname '*foo*'
./This is a foo file.txt
$ cat "$(!!)"
cat "$(find -iname '*foo*')"
This is just a test.
Yep!
Or:
$ ls -al subdir
ls: cannot open directory 'subdir': Permission denied
$ sudo !!
sudo ls -al subdir
total 0
drwx------ 2 root root 60 Jun 20 19:39 .
drwx------ 7 jess jess 360 Jun 20 19:39 ..
-rw-r--r-- 1 root root 0 Jun 20 19:39 nothing-to-see
@movq@www.uninformativ.de I’m feeling SO dumb right now 😅 I used to think !!
was a sudo
argument and never used it out of that context! Thanks for the $(!!)
tip 🤘