-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.completions.bash
executable file
·45 lines (37 loc) · 1.28 KB
/
git.completions.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# shellcheck shell=bash
cite about-completion
about-completion 'Git bash completions'
# Make sure git is installed
_command_exists git || return
# Don't handle completion if it's already managed
if complete -p git &> /dev/null; then
_log_warning "completion already loaded - this usually means it is safe to stop using this completion"
return 0
fi
_git_bash_completion_xcrun_git=
if _command_exists xcrun; then
_git_bash_completion_xcrun_git="$(xcrun --find git)"
fi
_git_bash_completion_paths=(
# Standard locations
"${GIT_EXE%/*}/../share/git-core/git-completion.bash"
"${GIT_EXE%/*}/../share/git-core/contrib/completion/git-completion.bash"
"${GIT_EXE%/*}/../etc/bash_completion.d/git-completion.bash"
# MacOS non-system locations
"${_git_bash_completion_xcrun_git%/bin/git}/share/git-core/git-completion.bash"
)
# Load the first completion file found
_git_bash_completion_found=false
for _comp_path in "${_git_bash_completion_paths[@]}"; do
if [[ -r "$_comp_path" ]]; then
_git_bash_completion_found=true
# shellcheck disable=SC1090 # don't follow
source "$_comp_path"
break
fi
done
# Cleanup
if [[ "${_git_bash_completion_found}" == false ]]; then
_log_warning "no completion files found - please try enabling the 'system' completion instead."
fi
unset "${!_git_bash_completion@}"