1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-09 22:36:14 +01:00

Merge pull request #736 from lethliel/improve_bash_completion

improve speed of bash completion
This commit is contained in:
Marco Strigl 2020-03-23 13:36:14 +01:00 committed by GitHub
commit 93a5a4d353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

11
dist/osc.complete vendored
View File

@ -160,15 +160,14 @@ projects ()
done
shift $argc
cur="$1"
if test -n "${cur}" ; then
list=($(command grep -E "^${cur}" ${projects}))
else
list=($(command cat ${projects}))
fi
if ((colon)) ; then
local colon_word
colon_word=${cur%${cur##*:}}
builtin compgen -W "${list[*]}" -- "${cur}" | sed -r "s@^${colon_word}@@g"
if test -n "${cur}" ; then
builtin compgen -W '`grep -E "^${cur}" ${projects}`' -- "${cur}" | sed -r "s@^${colon_word}@@g"
else
builtin compgen -W '`cat ${projects}`' -- "${cur}" | sed -r "s@^${colon_word}@@g"
fi
else
builtin compgen -W "${list[*]}" -- "${cur}"
fi