zsh 问题:在提示符附近显示最新的文件或目录以及建议的最新文件或目录

发布于 2025-01-15 03:45:36 字数 1482 浏览 5 评论 0原文

在 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,我有以下建议:

FIRST 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 :

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听风吹 2025-01-22 03:45:36

要列出按创建/出生日期/时间排序的文件,您可以使用:

ls -lt --time=birth

因此,所有建议都应按从最新到最旧的顺序排列

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

此外,如果您喜欢彩色输出在控制台中,您可以检查 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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文