Merge pull request #1976 from gaelicWizard/utilities

Use `_bash-it-egrep()`
pull/1984/head
Noah Gorny 2021-10-23 23:33:04 +03:00 committed by GitHub
commit c90a6283ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 10 deletions

View File

@ -711,8 +711,8 @@ _enable-thing ()
# Load the priority from the file if it present there # Load the priority from the file if it present there
declare local_file_priority use_load_priority declare local_file_priority use_load_priority
local_file_priority=$(grep -E "^# BASH_IT_LOAD_PRIORITY:" "${BASH_IT}/$subdirectory/available/$to_enable" | awk -F': ' '{ print $2 }') local_file_priority="$(_bash-it-egrep "^# BASH_IT_LOAD_PRIORITY:" "${BASH_IT}/$subdirectory/available/$to_enable" | awk -F': ' '{ print $2 }')"
use_load_priority=${local_file_priority:-$load_priority} use_load_priority="${local_file_priority:-$load_priority}"
ln -s ../$subdirectory/available/$to_enable "${BASH_IT}/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}" ln -s ../$subdirectory/available/$to_enable "${BASH_IT}/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}"
fi fi

3
lib/search.bash 100644 → 100755
View File

@ -57,7 +57,6 @@ _bash-it-search() {
local component local component
export BASH_IT_SEARCH_USE_COLOR=true export BASH_IT_SEARCH_USE_COLOR=true
export BASH_IT_GREP=${BASH_IT_GREP:-$(which egrep)}
declare -a BASH_IT_COMPONENTS=(aliases plugins completions) declare -a BASH_IT_COMPONENTS=(aliases plugins completions)
if [[ -z "$*" ]] ; then if [[ -z "$*" ]] ; then
@ -168,7 +167,7 @@ ${echo_underline_yellow}SUMMARY${echo_normal}
_bash-it-is-partial-match() { _bash-it-is-partial-match() {
local component="$1" local component="$1"
local term="$2" local term="$2"
_bash-it-component-help "${component}" | $(_bash-it-grep) -E -i -q -- "${term}" _bash-it-component-help "${component}" | _bash-it-egrep -i -q -- "${term}"
} }
_bash-it-component-term-matches-negation() { _bash-it-component-term-matches-negation() {

View File

@ -82,7 +82,7 @@ function _bash-it-component-help() {
file="$(_bash-it-component-cache-file "${component}")" file="$(_bash-it-component-cache-file "${component}")"
if [[ ! -s "${file}" || -z "$(find "${file}" -mmin -300)" ]]; then if [[ ! -s "${file}" || -z "$(find "${file}" -mmin -300)" ]]; then
func="_bash-it-${component}" func="_bash-it-${component}"
"${func}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E ' \[' >| "${file}" "${func}" | _bash-it-egrep ' \[' >| "${file}"
fi fi
cat "${file}" cat "${file}"
} }
@ -130,17 +130,17 @@ function _bash-it-component-list-matching() {
local component="$1" local component="$1"
shift shift
local term="$1" local term="$1"
_bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -- "${term}" | awk '{print $1}' | sort -u _bash-it-component-help "${component}" | _bash-it-egrep -- "${term}" | awk '{print $1}' | sort -u
} }
function _bash-it-component-list-enabled() { function _bash-it-component-list-enabled() {
local IFS=$'\n' component="$1" local IFS=$'\n' component="$1"
_bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E '\[x\]' | awk '{print $1}' | sort -u _bash-it-component-help "${component}" | _bash-it-egrep '\[x\]' | awk '{print $1}' | sort -u
} }
function _bash-it-component-list-disabled() { function _bash-it-component-list-disabled() {
local IFS=$'\n' component="$1" local IFS=$'\n' component="$1"
_bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -v '\[x\]' | awk '{print $1}' | sort -u _bash-it-component-help "${component}" | _bash-it-egrep -v '\[x\]' | awk '{print $1}' | sort -u
} }
# Checks if a given item is enabled for a particular component/file-type. # Checks if a given item is enabled for a particular component/file-type.
@ -154,7 +154,7 @@ function _bash-it-component-list-disabled() {
function _bash-it-component-item-is-enabled() { function _bash-it-component-item-is-enabled() {
local component="$1" local component="$1"
local item="$2" local item="$2"
_bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E '\[x\]' | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -q -- "^${item}\s" _bash-it-component-help "${component}" | _bash-it-egrep '\[x\]' | _bash-it-egrep -q -- "^${item}\s"
} }
# Checks if a given item is disabled for a particular component/file-type. # Checks if a given item is disabled for a particular component/file-type.
@ -168,5 +168,5 @@ function _bash-it-component-item-is-enabled() {
function _bash-it-component-item-is-disabled() { function _bash-it-component-item-is-disabled() {
local component="$1" local component="$1"
local item="$2" local item="$2"
_bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -v '\[x\]' | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -q -- "^${item}\s" _bash-it-component-help "${component}" | _bash-it-egrep -v '\[x\]' | _bash-it-egrep -q -- "^${item}\s"
} }