4 ms·
[zsh]$ ls -l *(Lm+10om) zsh supports extended globs, this says: -l give me a long listing “*(…)” of any file Lm+10 who’s size “L” in megabytes “m”
by CraigJPerry 4y ago
[zsh]$ ls -l *(Lm+10om)
zsh supports extended globs, this says:
-l give me a long listing
“*(…)” of any file
Lm+10 who’s size “L” in megabytes “m” is greater than 10
“om” ordered by modification ascending
- loeg 4y agoWouldn't you want to use 'ls -lt' (sort by time) (or possibly with '-r' if you really want oldest first)? (I.e., does 'om' sort the glob passed to 'ls', which it will then reorder, or does zsh do something magic with the 'ls' command?)
- CraigJPerry 4y agoyeah if you were typing this case yourself you would use -lt but i figured it was worth showing that extended globs can be combined. This globbing functionality in zsh is separate from the ls command, so no ls magic here, but the ls builtin in zsh does have some useful extras in it all the same
- orf 4y agoCool but that’s as opaque and hard to understand as sacrificing a goat to order ls output. It’s of course possible to do with existing shells, but it’s impossible to argue that it’s a clear
- CraigJPerry 4y agoDepends what you’re optimising for. Are you optimising for readability - e.g. maybe you share shell history with team mates for example. Or are you optimising for getting your thoughts transcribed to the machine as quickly as possible. It’s usually this case for me. I tend to maintain a huge shell history so i really like the terse format for quickly filtering down my historical commands. Writing shell scripts might be a good case for the longer form style although bourne-esque syntax is burned into my fingertips after all these years that long form is not going to be useful to me.
- orf 4y agoI also maintain a huge shell history, but in my experience fzf-ing through it becomes a lot harder when it’s terse and unreadable. But sure, there’s a tension between readability and brain-to-command throughput that’s always been there. The way you proposed is a bit too write-only for my taste, and the argument that you “had to learn it and now you’re muscle memory bound to it” is applicable to you only and does not preclude a better way from existing.
- reddit_clone 4y agoI use a trick to improve this. I too have a 7 year Shell history with Fzf and love using it as my second brain. I put #tags at the end of long, opaque, reusable commands so that I can FZF search it quicker.
- frankjr 4y agoI had no idea Zsh could do that. I'm currently reading this article which explains a lot of this wizardry. https://thevaluable.dev/zsh-expansion-guide-example/ https://thevaluable.dev/zsh-expansion-guide-example/