Merge pull request #686 from kigster/faster-search
Faster search, and cleaner completionpull/690/head
commit
c52bba24a5
|
|
@ -65,7 +65,7 @@ _bash-it-comp()
|
||||||
COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
update)
|
update | search)
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
enable | disable)
|
enable | disable)
|
||||||
|
|
|
||||||
|
|
@ -176,12 +176,14 @@ _bash-it-search-component() {
|
||||||
|
|
||||||
_component=$1
|
_component=$1
|
||||||
local func=_bash-it-${_component}
|
local func=_bash-it-${_component}
|
||||||
|
local help=$($func)
|
||||||
|
|
||||||
shift
|
shift
|
||||||
declare -a terms=($@)
|
declare -a terms=($@)
|
||||||
declare -a matches=()
|
declare -a matches=()
|
||||||
local _grep=$(which egrep || which grep)
|
local _grep=$(which egrep || which grep)
|
||||||
for term in "${terms[@]}"; do
|
for term in "${terms[@]}"; do
|
||||||
local term_match=($($func | ${_grep} -i -- ${term} | cut -d ' ' -f 1 | tr '\n' ' '))
|
local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | cut -d ' ' -f 1 | tr '\n' ' '))
|
||||||
[[ "${#term_match[@]}" -gt 0 ]] && {
|
[[ "${#term_match[@]}" -gt 0 ]] && {
|
||||||
matches=(${matches[@]} ${term_match[@]})
|
matches=(${matches[@]} ${term_match[@]})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue