3

When I use Zsh file completion on my downloads directory, it would be useful if it would show the files sorted by modification time.

This command will do so for all file completions:

zstyle ':completion:*' file-sort modification

How would I apply this only to files in ~/Downloads?

Edit: As Gilles suggests this is not possible, could I bind another key to file completion with file-sort modification?

jcassee
  • 71
  • 1
  • 5
  • Looking at the code of `_path_files`, it appears that the sorting order is picked before analyzing the path to determine what directory the file is in. So this would require a rehaul of `_path_files`. – Gilles 'SO- stop being evil' Mar 24 '16 at 21:03
  • So... not really possible at the moment? Maybe I could bind a different key to completing with `file-sort modification `? – jcassee Mar 25 '16 at 07:11
  • This doesn’t really answer your question, so I’ll just leave a comment: You could define a new completion widget with `zle -C` to do menu completion with files sorted by modification time, then bind this widget to a different key. This exact example occurs in the last chapter — in fact, on the penultimate page – of the zsh book (Kiddle et al.) – wjv Apr 11 '16 at 07:03
  • @wjv: Actually, this is a great response to my secondary question. Any way I can give you points? – jcassee Apr 11 '16 at 13:13
  • @JoostCassee No worries, as long as it helped you out with something! – wjv Apr 11 '16 at 13:37

0 Answers0