supercrabtree / k

k is the new l, yo
1.78k stars 124 forks source link

Add options for sort order #84

Closed reduxionist closed 6 years ago

reduxionist commented 6 years ago

Sort options are as per ls, except: -Version and extension sort not implemented due to lack of a direct glob sort equivalent, should they be desired in future they can be added to current implementation via either oe and lambda or o+ and function qualifiers. -Long-form time args can be passed directly after --sort (ls requires: --sort=time --time=long-arg-name)
-Long args will override flags if both are used (ls: last-seen wins) Sort order applies within directory args, not between the args themselves.

reduxionist commented 6 years ago

Also note that if in future k uses a shell unit-test framework, there's a test-case comparing k sort output against ls sort output that I'd be happy to adapt. I wasn't sure of the status of the javascript testing branch, so I have just left it out for now...

dmitry-saritasa commented 6 years ago

is it possible to sort so dirs come first? for example right now I have this

alias ls='LC_COLLATE=C ls -h --group-directories-first --color=auto'

possible with K?

reduxionist commented 6 years ago

Although it's not currently implemented, I will try adding the relevant glob qualifier and see what it gets us once I'm back in front of a terminal later today...

reduxionist commented 6 years ago

Support for --group-directories-first has been added, fresh-eyes testing would be appreciated. :smile: Pending merge to master, install via 'antigen bundle reduxionist/k --branch=add-sort-options' or equivalent.

dmitry-saritasa commented 6 years ago

Worked for me!

dmitry-saritasa commented 6 years ago
Projects/1k/frontend on  develop [$!] 
➜ antigen update
Updating andrewferrier/fzf-z... Done. Took 0s.
Updating arialdomartini/oh-my-git... Done. Took 0s.
Updating caarlos0/zsh-pg... Done. Took 1s.
Updating denysdovhan/spaceship-zsh-theme... Done. Took 0s.
Updating fabiokiatkowski/exercism.plugin.zsh... Done. Took 0s.
Updating gerges/oh-my-zsh-jira-plus... Done. Took 1s.
Updating horosgrisa/zsh-dropbox... Done. Took 0s.
Updating johnhamelink/env-zsh... Done. Took 0s.
Updating marzocchi/zsh-notify... Done. Took 1s.
Updating molovo/tipz... Done. Took 0s.
Updating robbyrussell/oh-my-zsh... Done. Took 1s.
Updating robertzk/send.zsh... Done. Took 0s.
Updating srijanshetty/zsh-pip-completion... Done. Took 0s.
Updating supercrabtree/k... Done. Took 1s.
Updating svenXY/timewarrior... Done. Took 0s.
Updating uvaes/fzf-marks... Done. Took 0s.
Updating valentinocossar/sublime... Done. Took 1s.
Updating zdharma/zsh-diff-so-fancy... Done. Took 0s.
Updating zsh-users/zsh-history-substring-search... Done. Took 0s.
Updating zsh-users/zsh-syntax-highlighting... Done. Took 1s.
Deprecated in favor of antigen reset.
rm: remove regular file '/home/dmitry/.antigen/.cache/.zcache-payload'? y
rm: remove regular file '/home/dmitry/.antigen/.cache/.zcache-bundles'? y
Done. Please open a new shell to see the changes.
Projects/1k/frontend on  develop [$!] 
➜ antigen update
Updating andrewferrier/fzf-z... Done. Took 0s.
Updating arialdomartini/oh-my-git... Done. Took 0s.
Updating caarlos0/zsh-pg... Done. Took 1s.
Updating denysdovhan/spaceship-zsh-theme... Done. Took 0s.
Updating fabiokiatkowski/exercism.plugin.zsh... Done. Took 0s.
Updating gerges/oh-my-zsh-jira-plus... Done. Took 1s.
Updating horosgrisa/zsh-dropbox... Done. Took 0s.
Updating johnhamelink/env-zsh... Done. Took 0s.
Updating marzocchi/zsh-notify... Done. Took 1s.
Updating molovo/tipz... Done. Took 0s.
Updating robbyrussell/oh-my-zsh... Done. Took 1s.
Updating robertzk/send.zsh... Done. Took 0s.
Updating srijanshetty/zsh-pip-completion... Done. Took 0s.
Updating supercrabtree/k... Done. Took 1s.
Updating svenXY/timewarrior... Done. Took 0s.
Updating uvaes/fzf-marks... Done. Took 0s.
Updating valentinocossar/sublime... Done. Took 1s.
Updating zdharma/zsh-diff-so-fancy... Done. Took 0s.
Updating zsh-users/zsh-history-substring-search... Done. Took 0s.
Updating zsh-users/zsh-syntax-highlighting... Done. Took 1s.
Deprecated in favor of antigen reset.
rm: remove regular file '/home/dmitry/.antigen/.cache/.zcache-payload'? y
rm: remove regular file '/home/dmitry/.antigen/.cache/.zcache-bundles'? y
Done. Please open a new shell to see the changes.

on restart, I got this

home/dmitry/.antigen/.cache/.zcache-payload:source:5420: no such file or directory: /home/dmitry/.antigen/.cache/lib/utils.zsh
/home/dmitry/.antigen/.cache/.zcache-payload:source:5423: no such file or directory: /home/dmitry/.antigen/.cache/lib/hooks.zsh
/home/dmitry/.antigen/.cache/.zcache-payload:source:5426: no such file or directory: /home/dmitry/.antigen/.cache/lib/section.zsh
zsh: spaceship::union: command not found...
zsh: spaceship::deprecated: command not found...
zsh: spaceship::deprecated: command not found...
zsh: spaceship::deprecated: command not found...
zsh: spaceship::deprecated: command not found...
zsh: spaceship::deprecated: command not found...
zsh: spaceship_exec_time_precmd_hook: function definition file not found        
zsh: spaceship_exec_vcs_info_precmd_hook: function definition file not found
zsh: spaceship::compose_prompt: command not found...
zsh: spaceship::compose_prompt: command not found...
zsh: spaceship::compose_prompt: command not found...
zsh: spaceship::compose_prompt: command not found...
zsh: spaceship::compose_prompt: command not found...
zsh: spaceship::compose_prompt: command not found...
zsh: spaceship::compose_prompt: command not found...
reduxionist commented 6 years ago

Hmmm, that's disappointing for sure! Let me look into spaceship and antigen caching to see how it could all be related and I'll get back to you within 24 hours from now. I'm assuming the current versions of each, and a generic enough linux, but let me know if there's any specifics I should be aware of, environment wise. Thanks for helping out with testing, it's always needed... :blush:

dmitry-saritasa commented 6 years ago

Jonathan @reduxionist I think this is not related to "k", but just in case I reported this bug to spaceship theme https://github.com/denysdovhan/spaceship-prompt/issues/469

If I disable "spaceship prompt" then everything works (for now I have used a different theme)

reduxionist commented 6 years ago

Oh great, it didn't sound k-related to me either but given the timing I thought it best not to make any assumptions. I actually use spaceship myself, and even after having forced an upgrade, mine has no issue with k-head, but I don't use antigen so probably an issue with spaceship and antigen caching. Anyway, if anything comes back as k-related please don't hesitate to let me know! :)

supercrabtree commented 6 years ago

hi @reduxionist I have not forgotten about this, I've just been really busy for the last few weeks. I will get to it asap. Thanks again :)

reduxionist commented 6 years ago

No problem, I hadn’t thought anything of it yet, just the normal ebb and flow of free-time to deadline when working on multiple projects concurrently. :smile: Actually, --group-directories-first showed me that custom sort expressions could fill our needs quite cleanly, so I’ll do by-extension next and hopefully get to by-version after that. Guidance on a testing-framework, however, would be of benefit the earlier it’s available. If you don't intend to resume with the javascript branch, then the language future contributors are guaranteed to be comfortable in now has viable options in every flavor of testing you might prefer: from the dominant xunit gang, through bdd/rspec, lightweight/micro, oop, to "UNIX-philosophy" and including even purpose-built for zsh itself frameworks. While it’s not quite the java testing ecosystem, I’m still impressed that even stubbing libraries are available from it now....

supercrabtree commented 6 years ago

Excellent stuff, sorry it took me so long to test this.

reduxionist commented 6 years ago

Thrilled you liked it! Given that's the case, I will submit a PR for sort-by-extension as soon as this RSI-enforced downtime has expired. I'm guessing most appropriate to append to this one, but let me know if you would rather a new PR instead...

supercrabtree commented 6 years ago

Could you open a new PR instead please, this ones is a little busy already. Cheers 🙂

reduxionist commented 4 years ago

Closes #50