0

On MacOS Big Sur 11.3, here is my .zshrc. I would like to get the newest files or directories near to the prompt (sorted from the most recent up to the oldest ones).

For the moment, I make test with the following command alias of ls :

The issue is that when I press TAB after a "l" which is actually the alias:

alias l='grc -es --colour=auto ls --color -Gh -C -lrt'

grc is a tool to colorify the files.

Here my current config in ~/.zshrc :

# ZSH completion
autoload -Uz compinit
compinit

# Colorize completions using default `ls` colors.
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"

# Zsh reverse auto-completion
zmodload zsh/complist

# To get new binaries into PATH
zstyle ':completion:*' rehash true

# Completion
zstyle ':completion:*:complete:(ls|cd|cp|mv|vim|cat|more|tail|head|open):*' file-sort date reverse

bindkey '^[[Z' menu-complete

If I do a FIRST l + space + TAB, I have the following suggestion :

FIRST TAB

If I type a SECOND pushing on TAB, I want a correct listing ordered from oldest to newest files automatically like this :

listing from oldest to newest

Finally, I want that a THIRD TAB pushing suggests the most recent file or directory (that I can browse with SHIFT + TAB)

in my case from figure above, the first suggestion that should appear is filenme_2.

But currently, the first suggestion with a THIRD TAB is the oldest one : this is not what I want.

Maybe there is something to do like adding :

bindkey '^\t' reverse-menu-complete or something slightly different but I can't succeed since with this bindkey, I have the suggestion as soon as I have pushed the FIRST TAB.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • This looks pretty close to a duplicate of https://stackoverflow.com/questions/70041237/zsh-listing-and-suggestions – DavidW Apr 30 '22 at 22:57
  • @DavidW . Yes this is close but I can't delete it otherwise there are risks that my account to be suspended given the fact there is an answer but this latter answer doesn't work. If moderators can delete it without suspending, I agree. –  May 01 '22 at 07:00
  • 1
    This question represents a significant vandalism of the original question, and is yet another tedious instance of disrespecting the requirement for quality content on Stack Overflow. I assume this is why the OP has been banned permanently. I originally rolled this back to the original question state, but I realised this invalidated the sole answer, so I have reluctantly restored the new version. – halfer Jun 18 '22 at 22:10

1 Answers1

2

To list files sorted by creation/birth date/time, you can use:

ls -lt --time=birth

So all the suggestions should be ordered from the newest to the oldest

alias l='grc -es --colour=auto ls -lt --time=birth --color -Gh -C -lrt'

Also if you like colorful output in your console you can check colorls

Itamar Cohen
  • 340
  • 4
  • 15
wojtas
  • 43
  • 8
  • thanks, I didn't know this option. Unfortunately , this doesn't fix my issue. –  May 03 '22 at 20:11