git: enable zsh completion

Git ships with a zsh completion script, but this script was previously
only available at $out/share/git/contrib/completion/git-completion.zsh,
which is not a path (or a filename) that would be discovered by a
typical zsh installation. This commit symlinks that file to
$out/share/zsh/site-functions/_git, which is a more standard location.

That zsh completion script is mostly a wrapper around the Bash
completion script, so this commit also patches the former so that it can
"find" the latter.
This commit is contained in:
Benjamin Esham 2020-02-08 16:08:24 -08:00 committed by Frederik Rietdijk
parent 8847d57763
commit 35b403bf12

View File

@ -145,6 +145,12 @@ stdenv.mkDerivation {
ln -s $out/share/git/contrib/completion/git-completion.bash $out/share/bash-completion/completions/git
mkdir -p $out/etc/bash_completion.d
ln -s $out/share/git/contrib/completion/git-prompt.sh $out/etc/bash_completion.d/
mkdir -p $out/share/zsh/site-functions
ln -s $out/share/git/contrib/completion/git-completion.zsh $out/share/zsh/site-functions/_git
# Patch the zsh completion script so it can find the Bash completion script.
sed -i -e "/locations=(/a \${"\t\t"}'$out/share/git/contrib/completion/git-completion.bash'" \
$out/share/git/contrib/completion/git-completion.zsh
# grep is a runtime dependency, need to patch so that it's found
substituteInPlace $out/libexec/git-core/git-sh-setup \