Let me teach you about reverse-i-search in bash…
Yep, thats a good one. Another one,
ALT + .inputs the last argument from your last command, pressing it multiple times cycles thorough your past arguments.Nice, 30 years and I didn’t know this one. I always use the
$!for the last argument.I’ve never heard of
$!but we use Macs at work.Alt+.doesn’t work so I’ve been using$_.⌥+.does the trick for me on MacOS.Sorry, I should have been more clear … When ssh’d into a remote Unix machine from a Mac, it doesn’t me. I don’t think I’ve tried locally.
Just as a matter of interest, I just tried this and it simply printed ≤ on the console. I’m using
Terminaland Tahoe 26.2.I think for
Terminal.appyou have to enable “Use Option as Meta key”I’ll try to remember to check it out in the morning, thank you.
edit: This worked. This is amazing. Thank you so much.
I don’t even want to think about how much effort this has saved me.
Huh. And here I had aliased “history | grep” to hgrep and was using that.
Also ‘cd -’ and aliases… 😁
And in fish
history | grep 'ls -la' | sed 's/^[[:space:]]*[0-9]\+[[:space:]]*//' | sh$ sudo apt install sl
Try sl instead of ls, you’ll thank me later
To be even more efficient while being lazy, try oh-my-bash. You can start typing the beginning of a command and use arrow up to cycle through only those, instead of the whole history. So if you had a very long mount command and don’t want to type it again, type mount and up arrow until it can be found. Not very useful for ls -al but very appreciated on longer commands.
I personally use fzf to do basically the same thing, I just have to press ctrl-r before I start to type, and it does fuzzy matching to your history and shows more than one alternative at a time
cd -will bring you to the last directory you were in.I just alias
ls -lahtolsl.Yeah
lk = ls -larthfor me becauselkis right next to each other.
ls, ctrl+R
Significantly less up arrows
I leave ls alone and instead do
alias l='ls -latrF'I do sometimes just want to use the plain version, especially if I’m in a small terminal window for some reason. But I think my brain likes scanning 1D lists more than 2D grids, no matter whether I’m in a terminal or using a graphical file manager.
Plain version is the one to pipe output for further processing. ls | wc -l
People talking about history without mentioning the laziest answer is to use an alias, which bash usually has ll = la -la or my personal preference is ll = ls -lAh (list + Everything except
.and..+ human readable file size)






