mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-09-21 10:27:09 +00:00
completions/git: Refactor using brace expansions, etc.
- Use brace expansions to generate prefixed paths - Check if the completion file is non-empty - Specify explicit exit value to "return" for trap handlers - Clean up the initialization function after initialization
This commit is contained in:
parent
a8971e3c7d
commit
c6fb27acb9
@ -14,12 +14,10 @@ _omb_completion_git_initialize() {
|
||||
# contain prefix or suffix for architectures and versions.
|
||||
path="${path%/*}"
|
||||
local prefix="${path%/bin}" file
|
||||
for file in share/bash-completion/completions/git share/git-core/contrib/completion/git-completion.bash;
|
||||
do
|
||||
local _file="$prefix/$file"
|
||||
if [[ -f $_file && -r $_file ]]; then
|
||||
source "$_file"
|
||||
return
|
||||
for file in "$prefix"/share/{bash-completion/completions/git,git-core/contrib/completion/git-completion.bash}; do
|
||||
if [[ -f $file && -r $file && -s $file ]]; then
|
||||
source "$file"
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
done
|
||||
@ -27,3 +25,4 @@ _omb_completion_git_initialize() {
|
||||
fi
|
||||
}
|
||||
_omb_completion_git_initialize
|
||||
unset -f _omb_completion_git_initialize
|
||||
|
Loading…
Reference in New Issue
Block a user