本文介绍了仅显示的COM prePLY的bash完成选项给用户的子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个bash脚本完成,假设 COM prePLY =(AA / BA / AA / BB /)。当调用脚本时,完成选项看起来像这样给用户:

In a bash completion script, suppose COMPREPLY=(aa/ba/ aa/bb/). When the script is invoked, the completion options looks like this to the user:

$ foo aa/b<TAB>
aa/ba/
aa/bb/

不过,我想有过如何显示这些选项更多的控制。特别是,我想只显示给用户的每一个COM prePLY选项的子串,类似于现在目录完成在bash是如何工作的:

However, I want to have a bit more control over how these options are displayed. In particular, I want to show only a substring of each COMPREPLY option to the user, similar to how directory completion works in bash now:

$ foo aa/b<TAB>
ba/
bb/

有没有在bash这样做的什么办法?

Is there any way of doing this in bash?

推荐答案

我有同样的问题,我调整我怎么绑定完成函数来命令固定它。我知道这工作,当你正在处理的文件系统中的实际文件,我认为它会与任何有点像选项文件路径的工作,但我不知道。

I was having the same problem and I fixed it by adjusting how I bound the completion function to the command. I know this works when you are dealing with actual files in the filesystem, I think it will work with any sort of file path like options, but I'm not sure.

complete -F _fubar fubar

complete -o filenames -F _fubar fubar

有关详细信息:Programmable完成内建命令

这篇关于仅显示的COM prePLY的bash完成选项给用户的子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 17:01