zsh 问题:在提示符附近显示最新的文件或目录以及建议的最新文件或目录
在 MacOS Big Sur 11.3 上,这是我的 .zshrc
。我想获取提示附近的最新文件或目录(从最新到最旧的排序)。
目前,我使用以下命令别名 ls
进行测试:
问题是,当我在“l”(实际上是别名)后按 TAB 时:
alias l='grc -es --colour=auto ls --color -Gh -C -lrt'
grc
是一个给文件着色的工具。
这是我当前在 ~/.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
如果我执行第一个 l + space + TAB
,我有以下建议:
如果我输入一个第二次按 TAB
时,我想要一个从最旧到最新文件自动排序的正确列表,如下所示:
最后,我想要第三个 TAB
推 建议最近的文件或目录(我可以使用 SHIFT + TAB 浏览)
在我的例子中,根据上图
,应该出现的第一个建议是 filenme_2
。但目前,带有第三个 TAB
的第一个建议是最旧的:这不是我想要的。
也许需要做一些事情,例如添加:
bindkey '^\t'reverse-menu-complete
或稍微不同的东西,但我无法成功,因为使用这个bindkey,我一有建议已按下第一个 TAB
。
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 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
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要列出按创建/出生日期/时间排序的文件,您可以使用:
ls -lt --time=birth
因此,所有建议都应按从最新到最旧的顺序排列
此外,如果您喜欢彩色输出在控制台中,您可以检查 colorls
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
Also if you like colorful output in your console you can check colorls