k icon indicating copy to clipboard operation
k copied to clipboard

sort by date

Open jaromil opened this issue 10 years ago • 6 comments
trafficstars

Would be real nice to port the equivalent of the -t flag in ls to sort by date (most recent last).

Very useful for messy home dirs like mine :sweat_smile:

jaromil avatar Jul 20 '15 07:07 jaromil

Also suggest sorting by file size

k2xl avatar Jan 17 '18 23:01 k2xl

There's an implementation of sort by time (-s m/--sort m) and size (-s L/--sort L), including -r/--reverse direction, available at reduxionist/k/tree/feature/sort-options .

@jaromil @k2xl , if you guys could please give it a try and let me know what you think, then once it's looking good to us we can ask @supercrabtree whether he wants to add it, and then, if so, what needs to be done before issuing the PR...

Thanks for k @supercrabtree!

reduxionist avatar Feb 04 '18 06:02 reduxionist

Works great on my setup. For the record, to quickly install your branch with antigen:

antigen bundle reduxionist/k --branch=feature/sort-options

jaromil avatar Feb 11 '18 12:02 jaromil

Hello,

I have been neglecting k for a little too long. This feature sounds great, if you would like to submit a PR I would happily review and merge.

Thanks

supercrabtree avatar Apr 28 '18 06:04 supercrabtree

Cool, in that case: using zsh's sort globs as the options was the cleanest approach I saw. Substituting directly made the only change to existing lines a $SORT_GLOB appendix on the glob qualifiers. I subsequently noticed the design specification in #27, however, which suggests implementing the rest of ls's arg spec as is. The backwards-compatibility is one of the main reasons k keeps winning "ls alternative of choice" for me; I've invested too much muscle memory at the console to reprogram the synapses for those options now. Objectively, the average user is unlikely to be as fluent in glob qualifiers as they are with ls arguments, so I think it's worth adding a mapping step to go from ls sort arg input to zsh glob spec commands. Unless you say otherwise, I'll submit a PR for that first and just leave the current branch hanging for now in case you prefer the simpler implementation. In any case, should I rebase on the currently active branches or stick to master?

reduxionist avatar Apr 29 '18 19:04 reduxionist

Hi, sounds good, please use master as a base branch :)

supercrabtree avatar May 06 '18 08:05 supercrabtree