parent
a0a359f22c
commit
5043c78701
|
|
@ -77,6 +77,7 @@ completion/available/vuejs.completion.bash
|
||||||
completion/available/wpscan.completion.bash
|
completion/available/wpscan.completion.bash
|
||||||
|
|
||||||
# libraries
|
# libraries
|
||||||
|
lib/helpers.bash
|
||||||
lib/utilities.bash
|
lib/utilities.bash
|
||||||
|
|
||||||
# plugins
|
# plugins
|
||||||
|
|
|
||||||
156
lib/helpers.bash
156
lib/helpers.bash
|
|
@ -64,18 +64,18 @@ function _completion_exists() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _bash_it_homebrew_check()
|
function _bash_it_homebrew_check() {
|
||||||
{
|
if _binary_exists 'brew'; then
|
||||||
if _binary_exists 'brew'
|
# Homebrew is installed
|
||||||
then # Homebrew is installed
|
if [[ "${BASH_IT_HOMEBREW_PREFIX:-unset}" == 'unset' ]]; then
|
||||||
if [[ "${BASH_IT_HOMEBREW_PREFIX:-unset}" == 'unset' ]]
|
# variable isn't set
|
||||||
then # variable isn't set
|
|
||||||
BASH_IT_HOMEBREW_PREFIX="$(brew --prefix)"
|
BASH_IT_HOMEBREW_PREFIX="$(brew --prefix)"
|
||||||
else
|
else
|
||||||
true # Variable is set already, don't invoke `brew`.
|
true # Variable is set already, don't invoke `brew`.
|
||||||
fi
|
fi
|
||||||
else # Homebrew is not installed.
|
else
|
||||||
BASH_IT_HOMEBREW_PREFIX= # clear variable, if set to anything.
|
# Homebrew is not installed: clear variable.
|
||||||
|
BASH_IT_HOMEBREW_PREFIX=
|
||||||
false # return failure if brew not installed.
|
false # return failure if brew not installed.
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -96,8 +96,7 @@ alias reload_completion="$(_make_reload_alias completion completion)"
|
||||||
# shellcheck disable=SC2139
|
# shellcheck disable=SC2139
|
||||||
alias reload_plugins="$(_make_reload_alias plugin plugins)"
|
alias reload_plugins="$(_make_reload_alias plugin plugins)"
|
||||||
|
|
||||||
bash-it ()
|
function bash-it() {
|
||||||
{
|
|
||||||
about 'Bash-it help and maintenance'
|
about 'Bash-it help and maintenance'
|
||||||
param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload | restart | doctor ] '
|
param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload | restart | doctor ] '
|
||||||
param '2: component type [one of: alias(es) | completion(s) | plugin(s) ] or search term(s)'
|
param '2: component type [one of: alias(es) | completion(s) | plugin(s) ] or search term(s)'
|
||||||
|
|
@ -121,31 +120,43 @@ bash-it ()
|
||||||
|
|
||||||
case $verb in
|
case $verb in
|
||||||
show)
|
show)
|
||||||
func="_bash-it-$component";;
|
func="_bash-it-$component"
|
||||||
|
;;
|
||||||
enable)
|
enable)
|
||||||
func="_enable-$component";;
|
func="_enable-$component"
|
||||||
|
;;
|
||||||
disable)
|
disable)
|
||||||
func="_disable-$component";;
|
func="_disable-$component"
|
||||||
|
;;
|
||||||
help)
|
help)
|
||||||
func="_help-$component";;
|
func="_help-$component"
|
||||||
|
;;
|
||||||
doctor)
|
doctor)
|
||||||
func="_bash-it-doctor-$component";;
|
func="_bash-it-doctor-$component"
|
||||||
|
;;
|
||||||
search)
|
search)
|
||||||
_bash-it-search "$component" "$@"
|
_bash-it-search "$component" "$@"
|
||||||
return;;
|
return
|
||||||
|
;;
|
||||||
update)
|
update)
|
||||||
func="_bash-it-update-$component";;
|
func="_bash-it-update-$component"
|
||||||
|
;;
|
||||||
migrate)
|
migrate)
|
||||||
func="_bash-it-migrate";;
|
func="_bash-it-migrate"
|
||||||
|
;;
|
||||||
version)
|
version)
|
||||||
func="_bash-it-version";;
|
func="_bash-it-version"
|
||||||
|
;;
|
||||||
restart)
|
restart)
|
||||||
func="_bash-it-restart";;
|
func="_bash-it-restart"
|
||||||
|
;;
|
||||||
reload)
|
reload)
|
||||||
func="_bash-it-reload";;
|
func="_bash-it-reload"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
reference "bash-it"
|
reference "bash-it"
|
||||||
return;;
|
return
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# pluralize component if necessary
|
# pluralize component if necessary
|
||||||
|
|
@ -163,13 +174,11 @@ bash-it ()
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$verb" == "enable" || "$verb" == "disable" ]]
|
if [[ "$verb" == "enable" || "$verb" == "disable" ]]; then
|
||||||
then
|
|
||||||
# Automatically run a migration if required
|
# Automatically run a migration if required
|
||||||
_bash-it-migrate
|
_bash-it-migrate
|
||||||
|
|
||||||
for arg in "$@"
|
for arg in "$@"; do
|
||||||
do
|
|
||||||
"$func" "$arg"
|
"$func" "$arg"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
@ -197,50 +206,46 @@ function _is_function() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-aliases ()
|
function _bash-it-aliases() {
|
||||||
{
|
|
||||||
_about 'summarizes available bash_it aliases'
|
_about 'summarizes available bash_it aliases'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it-describe "aliases" "an" "alias" "Alias"
|
_bash-it-describe "aliases" "an" "alias" "Alias"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-completions ()
|
function _bash-it-completions() {
|
||||||
{
|
|
||||||
_about 'summarizes available bash_it completions'
|
_about 'summarizes available bash_it completions'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it-describe "completion" "a" "completion" "Completion"
|
_bash-it-describe "completion" "a" "completion" "Completion"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-plugins ()
|
function _bash-it-plugins() {
|
||||||
{
|
|
||||||
_about 'summarizes available bash_it plugins'
|
_about 'summarizes available bash_it plugins'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it-describe "plugins" "a" "plugin" "Plugin"
|
_bash-it-describe "plugins" "a" "plugin" "Plugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-update-dev() {
|
function _bash-it-update-dev() {
|
||||||
_about 'updates Bash-it to the latest master'
|
_about 'updates Bash-it to the latest master'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it-update- dev "$@"
|
_bash-it-update- dev "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-update-stable() {
|
function _bash-it-update-stable() {
|
||||||
_about 'updates Bash-it to the latest tag'
|
_about 'updates Bash-it to the latest tag'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it-update- stable "$@"
|
_bash-it-update- stable "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it_update_migrate_and_restart() {
|
function _bash-it_update_migrate_and_restart() {
|
||||||
_about 'Checks out the wanted version, pops directory and restart. Does not return (because of the restart!)'
|
_about 'Checks out the wanted version, pops directory and restart. Does not return (because of the restart!)'
|
||||||
_param '1: Which branch to checkout to'
|
_param '1: Which branch to checkout to'
|
||||||
_param '2: Which type of version we are using'
|
_param '2: Which type of version we are using'
|
||||||
if git checkout "$1" &> /dev/null
|
if git checkout "$1" &> /dev/null; then
|
||||||
then
|
|
||||||
echo "Bash-it successfully updated."
|
echo "Bash-it successfully updated."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Migrating your installation to the latest $2 version now..."
|
echo "Migrating your installation to the latest $2 version now..."
|
||||||
|
|
@ -256,7 +261,7 @@ _bash-it_update_migrate_and_restart() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-update-() {
|
function _bash-it-update-() {
|
||||||
_about 'updates Bash-it'
|
_about 'updates Bash-it'
|
||||||
_param '1: What kind of update to do (stable|dev)'
|
_param '1: What kind of update to do (stable|dev)'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
@ -268,7 +273,7 @@ _bash-it-update-() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
pushd "${BASH_IT?}" >/dev/null || return
|
pushd "${BASH_IT?}" > /dev/null || return
|
||||||
|
|
||||||
DIFF=$(git diff --name-status)
|
DIFF=$(git diff --name-status)
|
||||||
if [[ -n "$DIFF" ]]; then
|
if [[ -n "$DIFF" ]]; then
|
||||||
|
|
@ -338,7 +343,7 @@ _bash-it-update-() {
|
||||||
else
|
else
|
||||||
read -r -e -n 1 -p "Would you like to update to ${TARGET}($(git log -1 --format=%h "${TARGET}"))? [Y/n] " RESP
|
read -r -e -n 1 -p "Would you like to update to ${TARGET}($(git log -1 --format=%h "${TARGET}"))? [Y/n] " RESP
|
||||||
case "$RESP" in
|
case "$RESP" in
|
||||||
[yY]|"")
|
[yY] | "")
|
||||||
_bash-it_update_migrate_and_restart "$TARGET" "$version"
|
_bash-it_update_migrate_and_restart "$TARGET" "$version"
|
||||||
;;
|
;;
|
||||||
[nN])
|
[nN])
|
||||||
|
|
@ -399,7 +404,7 @@ function _bash-it-migrate() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-version() {
|
function _bash-it-version() {
|
||||||
_about 'shows current Bash-it version'
|
_about 'shows current Bash-it version'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
|
|
@ -437,7 +442,7 @@ _bash-it-version() {
|
||||||
cd - &> /dev/null || return
|
cd - &> /dev/null || return
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-doctor() {
|
function _bash-it-doctor() {
|
||||||
_about 'reloads a profile file with a BASH_IT_LOG_LEVEL set'
|
_about 'reloads a profile file with a BASH_IT_LOG_LEVEL set'
|
||||||
_param '1: BASH_IT_LOG_LEVEL argument: "errors" "warnings" "all"'
|
_param '1: BASH_IT_LOG_LEVEL argument: "errors" "warnings" "all"'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
@ -447,35 +452,35 @@ _bash-it-doctor() {
|
||||||
_bash-it-reload
|
_bash-it-reload
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-doctor-all() {
|
function _bash-it-doctor-all() {
|
||||||
_about 'reloads a profile file with error, warning and debug logs'
|
_about 'reloads a profile file with error, warning and debug logs'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it-doctor "${BASH_IT_LOG_LEVEL_ALL?}"
|
_bash-it-doctor "${BASH_IT_LOG_LEVEL_ALL?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-doctor-warnings() {
|
function _bash-it-doctor-warnings() {
|
||||||
_about 'reloads a profile file with error and warning logs'
|
_about 'reloads a profile file with error and warning logs'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it-doctor "${BASH_IT_LOG_LEVEL_WARNING?}"
|
_bash-it-doctor "${BASH_IT_LOG_LEVEL_WARNING?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-doctor-errors() {
|
function _bash-it-doctor-errors() {
|
||||||
_about 'reloads a profile file with error logs'
|
_about 'reloads a profile file with error logs'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it-doctor "${BASH_IT_LOG_LEVEL_ERROR?}"
|
_bash-it-doctor "${BASH_IT_LOG_LEVEL_ERROR?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-doctor-() {
|
function _bash-it-doctor-() {
|
||||||
_about 'default bash-it doctor behavior, behaves like bash-it doctor all'
|
_about 'default bash-it doctor behavior, behaves like bash-it doctor all'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it-doctor-all
|
_bash-it-doctor-all
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-restart() {
|
function _bash-it-restart() {
|
||||||
_about 'restarts the shell in order to fully reload it'
|
_about 'restarts the shell in order to fully reload it'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
|
|
@ -492,11 +497,11 @@ _bash-it-restart() {
|
||||||
exec "${0/-/}" --rcfile <(echo "source \"$HOME/$init_file\"; cd \"$saved_pwd\"")
|
exec "${0/-/}" --rcfile <(echo "source \"$HOME/$init_file\"; cd \"$saved_pwd\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-reload() {
|
function _bash-it-reload() {
|
||||||
_about 'reloads a profile file'
|
_about 'reloads a profile file'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
pushd "${BASH_IT?}" >/dev/null || return
|
pushd "${BASH_IT?}" > /dev/null || return
|
||||||
|
|
||||||
case $OSTYPE in
|
case $OSTYPE in
|
||||||
darwin*)
|
darwin*)
|
||||||
|
|
@ -513,8 +518,7 @@ _bash-it-reload() {
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-describe ()
|
function _bash-it-describe() {
|
||||||
{
|
|
||||||
_about 'summarizes available bash_it components'
|
_about 'summarizes available bash_it components'
|
||||||
_param '1: subdirectory'
|
_param '1: subdirectory'
|
||||||
_param '2: preposition'
|
_param '2: preposition'
|
||||||
|
|
@ -530,8 +534,7 @@ _bash-it-describe ()
|
||||||
local f
|
local f
|
||||||
local enabled
|
local enabled
|
||||||
printf "%-20s%-10s%s\n" "$column_header" 'Enabled?' 'Description'
|
printf "%-20s%-10s%s\n" "$column_header" 'Enabled?' 'Description'
|
||||||
for f in "${BASH_IT}/$subdirectory/available"/*.bash
|
for f in "${BASH_IT}/$subdirectory/available"/*.bash; do
|
||||||
do
|
|
||||||
# Check for both the old format without the load priority, and the extended format with the priority
|
# Check for both the old format without the load priority, and the extended format with the priority
|
||||||
declare enabled_files enabled_file
|
declare enabled_files enabled_file
|
||||||
enabled_file="${f##*/}"
|
enabled_file="${f##*/}"
|
||||||
|
|
@ -550,8 +553,7 @@ _bash-it-describe ()
|
||||||
printf '%s\n' "$ bash-it disable $file_type <$file_type name> [$file_type name]... -or- $ bash-it disable $file_type all"
|
printf '%s\n' "$ bash-it disable $file_type <$file_type name> [$file_type name]... -or- $ bash-it disable $file_type all"
|
||||||
}
|
}
|
||||||
|
|
||||||
_on-disable-callback()
|
function _on-disable-callback() {
|
||||||
{
|
|
||||||
_about 'Calls the disabled plugin destructor, if present'
|
_about 'Calls the disabled plugin destructor, if present'
|
||||||
_param '1: plugin name'
|
_param '1: plugin name'
|
||||||
_example '$ _on-disable-callback gitstatus'
|
_example '$ _on-disable-callback gitstatus'
|
||||||
|
|
@ -561,8 +563,7 @@ _on-disable-callback()
|
||||||
_command_exists "$callback" && "$callback"
|
_command_exists "$callback" && "$callback"
|
||||||
}
|
}
|
||||||
|
|
||||||
_disable-plugin ()
|
function _disable-plugin() {
|
||||||
{
|
|
||||||
_about 'disables bash_it plugin'
|
_about 'disables bash_it plugin'
|
||||||
_param '1: plugin name'
|
_param '1: plugin name'
|
||||||
_example '$ disable-plugin rvm'
|
_example '$ disable-plugin rvm'
|
||||||
|
|
@ -572,8 +573,7 @@ _disable-plugin ()
|
||||||
_on-disable-callback "$1"
|
_on-disable-callback "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
_disable-alias ()
|
function _disable-alias() {
|
||||||
{
|
|
||||||
_about 'disables bash_it alias'
|
_about 'disables bash_it alias'
|
||||||
_param '1: alias name'
|
_param '1: alias name'
|
||||||
_example '$ disable-alias git'
|
_example '$ disable-alias git'
|
||||||
|
|
@ -582,8 +582,7 @@ _disable-alias ()
|
||||||
_disable-thing "aliases" "alias" "$1"
|
_disable-thing "aliases" "alias" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
_disable-completion ()
|
function _disable-completion() {
|
||||||
{
|
|
||||||
_about 'disables bash_it completion'
|
_about 'disables bash_it completion'
|
||||||
_param '1: completion name'
|
_param '1: completion name'
|
||||||
_example '$ disable-completion git'
|
_example '$ disable-completion git'
|
||||||
|
|
@ -623,13 +622,13 @@ function _disable-thing() {
|
||||||
rm -f "$_bash_it_config_file"
|
rm -f "$_bash_it_config_file"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
plugin_global="$(command ls $ "${BASH_IT}/enabled"/[0-9]*"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash" 2>/dev/null | head -1)"
|
plugin_global="$(command ls $ "${BASH_IT}/enabled"/[0-9]*"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash" 2> /dev/null | head -1)"
|
||||||
if [[ -z "$plugin_global" ]]; then
|
if [[ -z "$plugin_global" ]]; then
|
||||||
# Use a glob to search for both possible patterns
|
# Use a glob to search for both possible patterns
|
||||||
# 250---node.plugin.bash
|
# 250---node.plugin.bash
|
||||||
# node.plugin.bash
|
# node.plugin.bash
|
||||||
# Either one will be matched by this glob
|
# Either one will be matched by this glob
|
||||||
plugin="$(command ls $ "${BASH_IT}/$subdirectory/enabled/"{[0-9]*"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash","${file_entity}.${suffix}.bash"} 2>/dev/null | head -1)"
|
plugin="$(command ls $ "${BASH_IT}/$subdirectory/enabled/"{[0-9]*"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash","${file_entity}.${suffix}.bash"} 2> /dev/null | head -1)"
|
||||||
if [[ -z "$plugin" ]]; then
|
if [[ -z "$plugin" ]]; then
|
||||||
printf '%s\n' "sorry, $file_entity does not appear to be an enabled $file_type."
|
printf '%s\n' "sorry, $file_entity does not appear to be an enabled $file_type."
|
||||||
return
|
return
|
||||||
|
|
@ -645,8 +644,7 @@ function _disable-thing() {
|
||||||
printf '%s\n' "$file_entity disabled."
|
printf '%s\n' "$file_entity disabled."
|
||||||
}
|
}
|
||||||
|
|
||||||
_enable-plugin ()
|
function _enable-plugin() {
|
||||||
{
|
|
||||||
_about 'enables bash_it plugin'
|
_about 'enables bash_it plugin'
|
||||||
_param '1: plugin name'
|
_param '1: plugin name'
|
||||||
_example '$ enable-plugin rvm'
|
_example '$ enable-plugin rvm'
|
||||||
|
|
@ -655,8 +653,7 @@ _enable-plugin ()
|
||||||
_enable-thing "plugins" "plugin" "$1" "$BASH_IT_LOAD_PRIORITY_DEFAULT_PLUGIN"
|
_enable-thing "plugins" "plugin" "$1" "$BASH_IT_LOAD_PRIORITY_DEFAULT_PLUGIN"
|
||||||
}
|
}
|
||||||
|
|
||||||
_enable-alias ()
|
function _enable-alias() {
|
||||||
{
|
|
||||||
_about 'enables bash_it alias'
|
_about 'enables bash_it alias'
|
||||||
_param '1: alias name'
|
_param '1: alias name'
|
||||||
_example '$ enable-alias git'
|
_example '$ enable-alias git'
|
||||||
|
|
@ -665,8 +662,7 @@ _enable-alias ()
|
||||||
_enable-thing "aliases" "alias" "$1" "$BASH_IT_LOAD_PRIORITY_DEFAULT_ALIAS"
|
_enable-thing "aliases" "alias" "$1" "$BASH_IT_LOAD_PRIORITY_DEFAULT_ALIAS"
|
||||||
}
|
}
|
||||||
|
|
||||||
_enable-completion ()
|
function _enable-completion() {
|
||||||
{
|
|
||||||
_about 'enables bash_it completion'
|
_about 'enables bash_it completion'
|
||||||
_param '1: completion name'
|
_param '1: completion name'
|
||||||
_example '$ enable-completion git'
|
_example '$ enable-completion git'
|
||||||
|
|
@ -706,7 +702,7 @@ function _enable-thing() {
|
||||||
_enable-thing "$subdirectory" "$file_type" "$to_enable" "$load_priority"
|
_enable-thing "$subdirectory" "$file_type" "$to_enable" "$load_priority"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
to_enable="$(command ls "${BASH_IT}/$subdirectory/available/$file_entity".*.bash 2>/dev/null | head -1)"
|
to_enable="$(command ls "${BASH_IT}/$subdirectory/available/$file_entity".*.bash 2> /dev/null | head -1)"
|
||||||
if [[ -z "$to_enable" ]]; then
|
if [[ -z "$to_enable" ]]; then
|
||||||
printf '%s\n' "sorry, $file_entity does not appear to be an available $file_type."
|
printf '%s\n' "sorry, $file_entity does not appear to be an available $file_type."
|
||||||
return
|
return
|
||||||
|
|
@ -714,13 +710,13 @@ function _enable-thing() {
|
||||||
|
|
||||||
to_enable="${to_enable##*/}"
|
to_enable="${to_enable##*/}"
|
||||||
# Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it.
|
# Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it.
|
||||||
enabled_plugin="$(command ls "${BASH_IT}/$subdirectory/enabled"/{[0-9][0-9][0-9]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}","${to_enable}"} 2>/dev/null | head -1)"
|
enabled_plugin="$(command ls "${BASH_IT}/$subdirectory/enabled"/{[0-9][0-9][0-9]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}","${to_enable}"} 2> /dev/null | head -1)"
|
||||||
if [[ -n "$enabled_plugin" ]]; then
|
if [[ -n "$enabled_plugin" ]]; then
|
||||||
printf '%s\n' "$file_entity is already enabled."
|
printf '%s\n' "$file_entity is already enabled."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
enabled_plugin_global="$(command compgen -G "${BASH_IT}/enabled/[0-9][0-9][0-9]${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}" 2>/dev/null | head -1)"
|
enabled_plugin_global="$(command compgen -G "${BASH_IT}/enabled/[0-9][0-9][0-9]${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}" 2> /dev/null | head -1)"
|
||||||
if [[ -n "$enabled_plugin_global" ]]; then
|
if [[ -n "$enabled_plugin_global" ]]; then
|
||||||
printf '%s\n' "$file_entity is already enabled."
|
printf '%s\n' "$file_entity is already enabled."
|
||||||
return
|
return
|
||||||
|
|
@ -740,16 +736,14 @@ function _enable-thing() {
|
||||||
printf '%s\n' "$file_entity enabled with priority $use_load_priority."
|
printf '%s\n' "$file_entity enabled with priority $use_load_priority."
|
||||||
}
|
}
|
||||||
|
|
||||||
_help-completions()
|
function _help-completions() {
|
||||||
{
|
|
||||||
_about 'summarize all completions available in bash-it'
|
_about 'summarize all completions available in bash-it'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it-completions
|
_bash-it-completions
|
||||||
}
|
}
|
||||||
|
|
||||||
_help-aliases()
|
function _help-aliases() {
|
||||||
{
|
|
||||||
_about 'shows help for all aliases, or a specific alias group'
|
_about 'shows help for all aliases, or a specific alias group'
|
||||||
_param '1: optional alias group'
|
_param '1: optional alias group'
|
||||||
_example '$ alias-help'
|
_example '$ alias-help'
|
||||||
|
|
@ -815,14 +809,14 @@ function _help-plugins() {
|
||||||
rm "$grouplist" 2> /dev/null
|
rm "$grouplist" 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
_help-update () {
|
function _help-update() {
|
||||||
_about 'help message for update command'
|
_about 'help message for update command'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
echo "Check for a new version of Bash-it and update it."
|
echo "Check for a new version of Bash-it and update it."
|
||||||
}
|
}
|
||||||
|
|
||||||
_help-migrate () {
|
function _help-migrate() {
|
||||||
_about 'help message for migrate command'
|
_about 'help message for migrate command'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
|
|
@ -843,8 +837,8 @@ function all_groups() {
|
||||||
rm "$file"
|
rm "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! _command_exists pathmunge
|
if ! _command_exists pathmunge; then
|
||||||
then function pathmunge () {
|
function pathmunge() {
|
||||||
about 'prevent duplicate directories in you PATH variable'
|
about 'prevent duplicate directories in you PATH variable'
|
||||||
group 'helpers'
|
group 'helpers'
|
||||||
example 'pathmunge /path/to/dir is equivalent to PATH=/path/to/dir:$PATH'
|
example 'pathmunge /path/to/dir is equivalent to PATH=/path/to/dir:$PATH'
|
||||||
|
|
@ -857,7 +851,7 @@ then function pathmunge () {
|
||||||
export PATH=$1:$PATH
|
export PATH=$1:$PATH
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# `_bash-it-find-in-ancestor` uses the shell's ability to run a function in
|
# `_bash-it-find-in-ancestor` uses the shell's ability to run a function in
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue