I'm writing a setup file for some wrapper scripts, and mapping these scripts to completions for underlying commands.
In my .bash_profile, this maps git's completions to git_wrapper:
complete -F _git git_wrapper
In my setup.sh, the following does not work because the script is not interactive (type _git
fails because _git
is not available in non-interactive shells):
if type _git &>/dev/null && ! grep "complete.*_git git_wrapper" ~/.bash_profile &>/dev/null ; then
echo "complete -F _git git_wrapper" >> ~/.bash_profile
fi
From within setup.sh, how can I check if the _git completion would be available to an interactive shell?