如何创建`git flow feature checkout`别名的完成?

时间:2016-11-19 12:40:22

标签: git git-flow git-completion

我已将.bash_aliases配置为:

alias gc="git checkout"
alias gcf="git flow feature checkout"
source ~/.git-completion.bash
__git_complete gc  _git_checkout
source ~/.git-flow-completion.bash
__git_complete gcf __git_flow_feature

但是当我尝试完成时,我应该选择checkout,然后我可以选择我的分支:

$ gcf 
checkout   diff       help       publish    rebase     track      
delete     finish     list       pull       start      

$ gcf checkout a
a_branch1 a_branch2

当我写checkout + a TAB

时,我应该自动选择gcf

1 个答案:

答案 0 :(得分:3)

我认为一个解决方案可能在于custom Git alias completion

  

如果使用格式为!f() { ... }; f的复杂别名,则可以使用null   命令:作为函数体中声明所需的第一个命令   完成风格。例如!f() { : git commit ; ... }; f会   告诉完成使用提交完成。这也适用于别名   形式!sh -c '...'。例如,!sh -c ': git commit ; ... '

因此,您首先需要在.gitconfig中设置Git别名:

[alias]
  ffc = "!ffc() { : git checkout ; git flow feature checkout $@ ; } && ffc"

然后将其链接到.bash_aliases

alias gcf="git ffc"

这是未经测试但我认为它会做你想要的。根据用例$@可能会修复的ffc别名\"$@\"中的WITH CTE AS ( SELECT id,name from ct1 WHERE id is not null ), cte2 as ( SELECT id,name from ct2 WHERE name is not null ) INSERT INTO ct3(id,name) --<< INSERT needs to go here select c1.id as id1,c2.name as name1 from cte as c1, cte2 as c2 --<< are you SURE you want a cross join here? on conflict (id) do update -- no need to update the ID column here as that is the one used for conflict detection set name = name1; 空格可能会有问题。