为 zsh 编写定制选项卡完成功能

发布于 2024-07-26 18:35:16 字数 266 浏览 5 评论 0原文

抱歉,如果我的 google fu 太弱了,但是:我只是想调整 zsh,以便我可以

someappname -s

使用 ~/somedir 的内容(文件名)

完成选项卡例如:

someapp -s f<tab>

应该根据以字母 f 开头的文件循环完成补全〜/某个目录。 所以我最终可能会得到一个像这样的命令行:“someapp -s foobar”。

Sorry if my google fu is too weak, but: I simply want to adjust zsh so that I can tab complete

someappname -s

using the contents (filenames) of ~/somedir

For example:

someapp -s f<tab>

should cycle through completions based on the files starting with the letter f in ~/somedir . So I might end up with a command line like: "someapp -s foobar".

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

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

发布评论

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

评论(2

暖伴 2024-08-02 18:35:16

更简单的方法:

compdef "_files -W ~/somedir -/" someappname

A simpler approach:

compdef "_files -W ~/somedir -/" someappname
铁憨憨 2024-08-02 18:35:16

好吧,我解决了这个问题:(github上的源

#compdef diakonos

typeset -A opt_args
local context state line
local sessiondir
sessiondir=${HOME}/.diakonos/sessions

_arguments -n -s -S \
  "-s[specify session]:session:_files -W $sessiondir" \
  "*:file:_files" \
  && return 0

return 1

我引用了http://www.linux-mag.com/id/1106([免费]注册需要阅读),并从 freenode 上的 #zsh 获得帮助。

Well, I worked this out: (source at github)

#compdef diakonos

typeset -A opt_args
local context state line
local sessiondir
sessiondir=${HOME}/.diakonos/sessions

_arguments -n -s -S \
  "-s[specify session]:session:_files -W $sessiondir" \
  "*:file:_files" \
  && return 0

return 1

I referenced http://www.linux-mag.com/id/1106 ([free] registration required to read), and got help from #zsh on freenode.

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