提交 a766b98b 编写于 作者: M Mislav Marohnić

Account for various locations of bash/zsh completion scripts

On different systems, bash/zsh completion scripts for git are installed
in various places. Account for that by searching the list of known paths.

In zsh mode, if a git-distributed zsh completion script can't be found
(e.g. on Ubuntu), ignore that and let it fall back to zsh-distributed
completion script.
上级 755d5aa0
......@@ -31,11 +31,14 @@ git_distributed_zsh_completion = lambda {
}
git_distributed_bash_completion = lambda {
git_prefix.call + 'share/git-core/contrib/completion/git-completion.bash'
[ git_prefix.call + 'share/git-core/contrib/completion/git-completion.bash',
Pathname.new('/etc/bash_completion.d/git'),
Pathname.new('/usr/share/bash-completion/completions/git'),
Pathname.new('/usr/share/bash-completion/git'),
].detect {|p| p.exist? }
}
link_completion = Proc.new { |from, name|
name ||= from.basename
raise ArgumentError, from.to_s unless File.exist?(from)
FileUtils.ln_s(from, cpldir + name, :force => true)
}
......@@ -162,8 +165,12 @@ Given(/^I'm using ((?:zsh|git)-distributed) base git completions$/) do |type|
(cpldir + '_git').exist?.should be_false
when 'git-distributed'
if 'zsh' == shell
link_completion.call(git_distributed_zsh_completion.call)
link_completion.call(git_distributed_bash_completion.call)
if git_distributed_zsh_completion.call.exist?
link_completion.call(git_distributed_zsh_completion.call, '_git')
link_completion.call(git_distributed_bash_completion.call, 'git-completion.bash')
else
warn "warning: git-distributed zsh completion wasn't found; using zsh-distributed instead"
end
end
else
raise ArgumentError, type
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册