'zsh issue : have the most recents files or directories near to the prompt and suggested most recent files or directories
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 :
If I type a SECOND pushing on TAB
, I want a correct listing ordered from oldest to newest files automatically like this :
Finally, I want that a THIRD TAB
pushing suggests the most recent file or directtory (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
.
Any track/clue is welcome.
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Itamar Cohen |