问题描述
假设我在 git-cc
中有一个 PATH
可执行文件。如果 git-cc
支持 --help
,那么很容易提供足够的补全
complete -F _longopt git-cc
这使得 $ git-cc --<TAB>
完整(根据帮助输出)。但是 git cc --<TAB>
不会完成(即使它运行良好)。更重要的是,如果我为自定义子命令创建一个 git 别名,例如cc-sensible-defaults = cc --opt1 ...
,这也不起作用,在这种情况下,简单地删除空格(git-cc
而不是 git cc
)不是一种选择。
怎么办?我试过搞乱 __git_complete [git-]cc _longopt
,但各种组合都没有任何好处。它似乎是为了完成 bash 别名(如 gl = git-log
),而不是子命令。正如预期的那样,git/git-completion.bash 中的介绍不是很有帮助,包含令人困惑的
# If you have a command that is not part of git,but you would still
# like completion,you can use __git_complete:
#
# __git_complete gl git_log
#
# Or if it's a main command (i.e. git or gitk):
#
# __git_complete gk gitk
(WTH 是 _git_log?他们的意思是 _git_log,这确实是一个函数?是某种约定吗?)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)