Skip to content

Commit

Permalink
Merge pull request #1976 from gaelicWizard/utilities
Browse files Browse the repository at this point in the history
Use `_bash-it-egrep()`
  • Loading branch information
NoahGorny committed Oct 23, 2021
2 parents 2d1bd82 + 00f5f2a commit c90a628
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,8 @@ _enable-thing ()

# Load the priority from the file if it present there
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 }')
use_load_priority=${local_file_priority:-$load_priority}
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}"

ln -s ../$subdirectory/available/$to_enable "${BASH_IT}/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}"
fi
Expand Down
3 changes: 1 addition & 2 deletions lib/search.bash
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ _bash-it-search() {

local component
export BASH_IT_SEARCH_USE_COLOR=true
export BASH_IT_GREP=${BASH_IT_GREP:-$(which egrep)}
declare -a BASH_IT_COMPONENTS=(aliases plugins completions)

if [[ -z "$*" ]] ; then
Expand Down Expand Up @@ -168,7 +167,7 @@ ${echo_underline_yellow}SUMMARY${echo_normal}
_bash-it-is-partial-match() {
local component="$1"
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() {
Expand Down
12 changes: 6 additions & 6 deletions lib/utilities.bash
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function _bash-it-component-help() {
file="$(_bash-it-component-cache-file "${component}")"
if [[ ! -s "${file}" || -z "$(find "${file}" -mmin -300)" ]]; then
func="_bash-it-${component}"
"${func}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E ' \[' >| "${file}"
"${func}" | _bash-it-egrep ' \[' >| "${file}"
fi
cat "${file}"
}
Expand Down Expand Up @@ -130,17 +130,17 @@ function _bash-it-component-list-matching() {
local component="$1"
shift
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() {
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() {
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.
Expand All @@ -154,7 +154,7 @@ function _bash-it-component-list-disabled() {
function _bash-it-component-item-is-enabled() {
local component="$1"
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.
Expand All @@ -168,5 +168,5 @@ function _bash-it-component-item-is-enabled() {
function _bash-it-component-item-is-disabled() {
local component="$1"
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"
}

0 comments on commit c90a628

Please sign in to comment.