parent
8cf24f19a2
commit
5fcd16e6cf
|
|
@ -74,6 +74,9 @@ completion/available/vault.completion.bash
|
||||||
completion/available/vuejs.completion.bash
|
completion/available/vuejs.completion.bash
|
||||||
completion/available/wpscan.completion.bash
|
completion/available/wpscan.completion.bash
|
||||||
|
|
||||||
|
# libraries
|
||||||
|
lib/utilities.bash
|
||||||
|
|
||||||
# plugins
|
# plugins
|
||||||
#
|
#
|
||||||
plugins/available/alias-completion.plugin.bash
|
plugins/available/alias-completion.plugin.bash
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
# Generic utilies
|
# Generic utilies
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
_bash-it-get-component-name-from-path() {
|
function _bash-it-get-component-name-from-path() {
|
||||||
# filename without path
|
# filename without path
|
||||||
filename="${1##*/}"
|
filename="${1##*/}"
|
||||||
# filename without path or priority
|
# filename without path or priority
|
||||||
|
|
@ -15,7 +15,7 @@ _bash-it-get-component-name-from-path() {
|
||||||
echo "${filename%.*.bash}"
|
echo "${filename%.*.bash}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-get-component-type-from-path() {
|
function _bash-it-get-component-type-from-path() {
|
||||||
local filename
|
local filename
|
||||||
# filename without path
|
# filename without path
|
||||||
filename="${1##*/}"
|
filename="${1##*/}"
|
||||||
|
|
@ -45,7 +45,7 @@ _bash-it-get-component-type-from-path() {
|
||||||
# contains pear!
|
# contains pear!
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
_bash-it-array-contains-element() {
|
function _bash-it-array-contains-element() {
|
||||||
local e
|
local e
|
||||||
for e in "${@:2}"; do
|
for e in "${@:2}"; do
|
||||||
[[ "$e" == "$1" ]] && return 0
|
[[ "$e" == "$1" ]] && return 0
|
||||||
|
|
@ -54,26 +54,23 @@ _bash-it-array-contains-element() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Dedupe a simple array of words without spaces.
|
# Dedupe a simple array of words without spaces.
|
||||||
_bash-it-array-dedup() {
|
function _bash-it-array-dedup() {
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
echo "$@" | tr ' ' '\n' | sort -u
|
echo "$@" | tr ' ' '\n' | sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
# Outputs a full path of the grep found on the filesystem
|
# Outputs a full path of the grep found on the filesystem
|
||||||
function _bash-it-grep()
|
function _bash-it-grep() {
|
||||||
{
|
|
||||||
: "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}"
|
: "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}"
|
||||||
printf "%s" "${BASH_IT_GREP:-'/usr/bin/grep'}"
|
printf "%s" "${BASH_IT_GREP:-'/usr/bin/grep'}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# Component-specific functions (component is either an alias, a plugin, or a
|
# Component-specific functions (component is either an alias, a plugin, or a
|
||||||
# completion).
|
# completion).
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
function _bash-it-component-help()
|
function _bash-it-component-help() {
|
||||||
{
|
|
||||||
local component file func
|
local component file func
|
||||||
component="$(_bash-it-pluralize-component "${1}")"
|
component="$(_bash-it-pluralize-component "${1}")"
|
||||||
file="$(_bash-it-component-cache-file "${component}")"
|
file="$(_bash-it-component-cache-file "${component}")"
|
||||||
|
|
@ -88,12 +85,12 @@ function _bash-it-component-help()
|
||||||
function _bash-it-component-cache-file() {
|
function _bash-it-component-cache-file() {
|
||||||
local component file
|
local component file
|
||||||
component="$(_bash-it-pluralize-component "${1}")"
|
component="$(_bash-it-pluralize-component "${1}")"
|
||||||
file="${BASH_IT}/tmp/cache/${component}"
|
file="${BASH_IT?}/tmp/cache/${component}"
|
||||||
[[ -f "${file}" ]] || mkdir -p "${file%/*}"
|
[[ -f "${file}" ]] || mkdir -p "${file%/*}"
|
||||||
printf '%s' "${file}"
|
printf '%s' "${file}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-pluralize-component() {
|
function _bash-it-pluralize-component() {
|
||||||
local component="${1}"
|
local component="${1}"
|
||||||
local -i len=$((${#component} - 1))
|
local -i len=$((${#component} - 1))
|
||||||
# pluralize component name for consistency
|
# pluralize component name for consistency
|
||||||
|
|
@ -102,7 +99,7 @@ _bash-it-pluralize-component() {
|
||||||
printf '%s' "${component}"
|
printf '%s' "${component}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-clean-component-cache() {
|
function _bash-it-clean-component-cache() {
|
||||||
local component="$1"
|
local component="$1"
|
||||||
local cache
|
local cache
|
||||||
local -a BASH_IT_COMPONENTS=(aliases plugins completions)
|
local -a BASH_IT_COMPONENTS=(aliases plugins completions)
|
||||||
|
|
@ -119,23 +116,24 @@ _bash-it-clean-component-cache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Returns an array of items within each compoenent.
|
# Returns an array of items within each compoenent.
|
||||||
_bash-it-component-list() {
|
function _bash-it-component-list() {
|
||||||
local IFS=$'\n' component="$1"
|
local IFS=$'\n' component="$1"
|
||||||
_bash-it-component-help "${component}" | awk '{print $1}' | sort -u
|
_bash-it-component-help "${component}" | awk '{print $1}' | sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-component-list-matching() {
|
function _bash-it-component-list-matching() {
|
||||||
local component="$1"; shift
|
local component="$1"
|
||||||
|
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_GREP:-$(_bash-it-grep)} -E -- "${term}" | awk '{print $1}' | sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
_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_GREP:-$(_bash-it-grep)} -E '\[x\]' | awk '{print $1}' | sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
_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_GREP:-$(_bash-it-grep)} -E -v '\[x\]' | awk '{print $1}' | sort -u
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +146,7 @@ _bash-it-component-list-disabled() {
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
# _bash-it-component-item-is-enabled alias git && echo "git alias is enabled"
|
# _bash-it-component-item-is-enabled alias git && echo "git alias is enabled"
|
||||||
_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_GREP:-$(_bash-it-grep)} -E '\[x\]' | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -q -- "^${item}\s"
|
||||||
|
|
@ -162,7 +160,7 @@ _bash-it-component-item-is-enabled() {
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
# _bash-it-component-item-is-disabled alias git && echo "git aliases are disabled"
|
# _bash-it-component-item-is-disabled alias git && echo "git aliases are disabled"
|
||||||
_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_GREP:-$(_bash-it-grep)} -E -v '\[x\]' | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -q -- "^${item}\s"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue