mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
completions/git: Support multiple git paths and resolve symlink
Co-authored-by: Koichi Murase <myoga.murase@gmail.com>
This commit is contained in:
committed by
Koichi Murase
parent
5516f7e2ed
commit
c106583722
@@ -1,10 +1,17 @@
|
||||
# bash completion support for Git.
|
||||
_omb_completion_git_initialize() {
|
||||
if ! _omb_util_function_exists __gitdir; then
|
||||
local path
|
||||
for path in $(type -aP git);
|
||||
do
|
||||
path="${path%/git}"
|
||||
local git_paths path
|
||||
IFS=$'\n' read -r -d '' -a git_paths <<< "$(type -aP git)"
|
||||
# Note: Falling back on /usr (should already be in the array)
|
||||
git_paths+=("/usr/bin/git")
|
||||
for path in "${git_paths[@]}"; do
|
||||
if [[ -L $path ]]; then
|
||||
path=$(readlink -f $path)
|
||||
fi
|
||||
# Note: In the case of symbolic link, the true binary name can
|
||||
# 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
|
||||
|
Reference in New Issue
Block a user