Files
bash-it/completion/available/git.completion.bash
John D Pell de9ea54b81 Don't call external uname when $OSTYPE will do (#1911)
* lib/helpers: use `$OSTYPE` instead of `$(uname)`

* plugins/osx: use `$OSTYPE` instead of `$(uname)`

* plugins/boot2docker: use `$OSTYPE` instead of `$(uname)`

* plugins/python: use `$OSTYPE` instead of `$(uname)`

* plugins/base: use `$OSTYPE` instead of `$(uname)`

Alsö, use `[[` instead of `[` as the former has less insane argument handling being shell syntax rather than a builtin command that must emulate being a real binary

* completion/brew: use `$OSTYPE` instead of `$(uname)`

* completion/git: use `$OSTYPE` instead of `$(uname)`

Alsö, use `[[` instead of `[`.

* completion/fabric: use `$OSTYPE` instead of `uname`

* theme/demula: use `$OSTYPE` instead of `$(uname)`

* theme/rana: use `$OSTYPE` instead of `$(uname)`
2021-08-14 10:20:12 +03:00

40 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Only operate on MacOS since there are no linux paths
if [[ "$OSTYPE" != 'darwin'* ]] ; then
_log_warning "unsupported operating system - only 'Darwin' is supported"
return 0
fi
# Make sure git is installed
_command_exists git || return 0
# 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_found=false
_git_bash_completion_paths=(
# MacOS non-system locations
'/Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash'
'/Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash'
)
# Load the first completion file found
for _comp_path in "${_git_bash_completion_paths[@]}" ; do
if [[ -r "$_comp_path" ]] ; then
_git_bash_completion_found=true
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_paths
unset _git_bash_completion_found