parent
6ed006a167
commit
003b0ce802
|
|
@ -78,6 +78,7 @@ completion/available/vuejs.completion.bash
|
||||||
completion/available/wpscan.completion.bash
|
completion/available/wpscan.completion.bash
|
||||||
|
|
||||||
# libraries
|
# libraries
|
||||||
|
lib/helpers.bash
|
||||||
lib/log.bash
|
lib/log.bash
|
||||||
lib/utilities.bash
|
lib/utilities.bash
|
||||||
|
|
||||||
|
|
|
||||||
205
lib/helpers.bash
205
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)'
|
||||||
|
|
@ -122,33 +121,46 @@ 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"
|
||||||
|
;;
|
||||||
profile)
|
profile)
|
||||||
func=_bash-it-profile-$component;;
|
func=_bash-it-profile-$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
|
||||||
|
|
@ -166,13 +178,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
|
||||||
|
|
||||||
|
|
@ -200,50 +210,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..."
|
||||||
|
|
@ -259,7 +265,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'
|
||||||
|
|
@ -271,7 +277,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
|
||||||
|
|
@ -341,7 +347,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])
|
||||||
|
|
@ -402,7 +408,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'
|
||||||
|
|
||||||
|
|
@ -440,7 +446,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'
|
||||||
|
|
@ -450,35 +456,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-profile-save() {
|
function _bash-it-profile-save() {
|
||||||
_about 'saves the current configuration to the "profile" directory'
|
_about 'saves the current configuration to the "profile" directory'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
|
|
@ -545,9 +551,9 @@ _bash-it-profile-save() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "Profile location: $profile_path"
|
echo "Profile location: $profile_path"
|
||||||
echo "Load the profile by invoking \"bash-it profile load $name\""
|
echo "Load the profile by invoking \"bash-it profile load $name\""
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-profile-load-parse-profile() {
|
_bash-it-profile-load-parse-profile() {
|
||||||
_about 'Internal function used to parse the profile file'
|
_about 'Internal function used to parse the profile file'
|
||||||
_param '1: path to the profile file'
|
_param '1: path to the profile file'
|
||||||
_param '2: dry run- only check integrity of the profile file'
|
_param '2: dry run- only check integrity of the profile file'
|
||||||
|
|
@ -562,7 +568,7 @@ _bash-it-profile-save() {
|
||||||
local subdirectory=${line[0]}
|
local subdirectory=${line[0]}
|
||||||
local component=${line[1]}
|
local component=${line[1]}
|
||||||
|
|
||||||
local to_enable=$(command ls "${BASH_IT}/$subdirectory/available/$component".*bash 2>/dev/null | head -1)
|
local to_enable=$(command ls "${BASH_IT}/$subdirectory/available/$component".*bash 2> /dev/null | head -1)
|
||||||
# Ignore botched lines
|
# Ignore botched lines
|
||||||
if [[ -z "${to_enable}" ]]; then
|
if [[ -z "${to_enable}" ]]; then
|
||||||
echo -e "${echo_orange?}Bad line(#$num) in profile, aborting load...${echo_reset_color?}"
|
echo -e "${echo_orange?}Bad line(#$num) in profile, aborting load...${echo_reset_color?}"
|
||||||
|
|
@ -577,9 +583,9 @@ _bash-it-profile-save() {
|
||||||
|
|
||||||
# Make sure to propagate the error
|
# Make sure to propagate the error
|
||||||
[[ -z $bad ]]
|
[[ -z $bad ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-profile-list() {
|
_bash-it-profile-list() {
|
||||||
about 'lists all profiles from the "profiles" directory'
|
about 'lists all profiles from the "profiles" directory'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
local profile
|
local profile
|
||||||
|
|
@ -589,9 +595,9 @@ _bash-it-profile-save() {
|
||||||
profile="${profile##*/}"
|
profile="${profile##*/}"
|
||||||
echo "${profile/.bash_it/}"
|
echo "${profile/.bash_it/}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-profile-rm() {
|
_bash-it-profile-rm() {
|
||||||
about 'Removes a profile from the "profiles" directory'
|
about 'Removes a profile from the "profiles" directory'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
|
|
@ -615,9 +621,9 @@ _bash-it-profile-save() {
|
||||||
|
|
||||||
command rm "$profile_path"
|
command rm "$profile_path"
|
||||||
echo "Removed profile \"$name\" successfully!"
|
echo "Removed profile \"$name\" successfully!"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-profile-load() {
|
_bash-it-profile-load() {
|
||||||
_about 'loads a configuration from the "profiles" directory'
|
_about 'loads a configuration from the "profiles" directory'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
|
|
@ -644,9 +650,9 @@ _bash-it-profile-save() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "Profile \"$name\" enabled!"
|
echo "Profile \"$name\" enabled!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_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'
|
||||||
|
|
||||||
|
|
@ -663,11 +669,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*)
|
||||||
|
|
@ -684,8 +690,7 @@ _bash-it-reload() {
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-determine-component-status-from-path ()
|
_bash-it-determine-component-status-from-path() {
|
||||||
{
|
|
||||||
_about 'internal function used to process component name and check if its enabled'
|
_about 'internal function used to process component name and check if its enabled'
|
||||||
_param '1: full path to available component file'
|
_param '1: full path to available component file'
|
||||||
_example '$ _bash-it-determine-component-status-from-path "${BASH_IT}/plugins/available/git.plugin.bash'
|
_example '$ _bash-it-determine-component-status-from-path "${BASH_IT}/plugins/available/git.plugin.bash'
|
||||||
|
|
@ -701,10 +706,9 @@ _bash-it-determine-component-status-from-path ()
|
||||||
else
|
else
|
||||||
enabled=' '
|
enabled=' '
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_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'
|
||||||
|
|
@ -720,8 +724,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
|
|
||||||
_bash-it-determine-component-status-from-path "$f"
|
_bash-it-determine-component-status-from-path "$f"
|
||||||
printf "%-20s%-10s%s\n" "$enabled_file_clean" " [$enabled]" "$(metafor "about-$file_type" < "$f")"
|
printf "%-20s%-10s%s\n" "$enabled_file_clean" " [$enabled]" "$(metafor "about-$file_type" < "$f")"
|
||||||
done
|
done
|
||||||
|
|
@ -731,8 +734,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'
|
||||||
|
|
@ -742,8 +744,7 @@ _on-disable-callback()
|
||||||
_command_exists "$callback" && "$callback"
|
_command_exists "$callback" && "$callback"
|
||||||
}
|
}
|
||||||
|
|
||||||
_disable-all ()
|
function _disable-all() {
|
||||||
{
|
|
||||||
_about 'disables all bash_it components'
|
_about 'disables all bash_it components'
|
||||||
_example '$ _disable-all'
|
_example '$ _disable-all'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
@ -751,10 +752,9 @@ _disable-all ()
|
||||||
_disable-plugin "all"
|
_disable-plugin "all"
|
||||||
_disable-alias "all"
|
_disable-alias "all"
|
||||||
_disable-completion "all"
|
_disable-completion "all"
|
||||||
}
|
}
|
||||||
|
|
||||||
_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'
|
||||||
|
|
@ -764,8 +764,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'
|
||||||
|
|
@ -774,8 +773,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'
|
||||||
|
|
@ -815,13 +813,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
|
||||||
|
|
@ -841,8 +839,7 @@ function _disable-thing() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_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'
|
||||||
|
|
@ -851,14 +848,12 @@ _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-plugins ()
|
function _enable-plugins() {
|
||||||
{
|
|
||||||
_about 'alias of _enable-plugin'
|
_about 'alias of _enable-plugin'
|
||||||
_enable-plugin "$@"
|
_enable-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'
|
||||||
|
|
@ -867,14 +862,12 @@ _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-aliases ()
|
function _enable-aliases() {
|
||||||
{
|
|
||||||
_about 'alias of _enable-alias'
|
_about 'alias of _enable-alias'
|
||||||
_enable-alias "$@"
|
_enable-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'
|
||||||
|
|
@ -914,7 +907,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
|
||||||
|
|
@ -922,13 +915,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
|
||||||
|
|
@ -948,16 +941,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'
|
||||||
|
|
@ -1023,7 +1014,7 @@ function _help-plugins() {
|
||||||
rm "$grouplist" 2> /dev/null
|
rm "$grouplist" 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
_help-profile () {
|
_help-profile() {
|
||||||
_about 'help message for profile command'
|
_about 'help message for profile command'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
|
|
@ -1032,16 +1023,16 @@ _help-profile () {
|
||||||
echo "Use 'bash-it profile save foo' to save the current configuration into a profile named 'foo'."
|
echo "Use 'bash-it profile save foo' to save the current configuration into a profile named 'foo'."
|
||||||
echo "Use 'bash-it profile load foo' to load an existing profile named 'foo'."
|
echo "Use 'bash-it profile load foo' to load an existing profile named 'foo'."
|
||||||
echo "Use 'bash-it profile rm foo' to remove an existing profile named 'foo'."
|
echo "Use 'bash-it profile rm foo' to remove an existing profile named 'foo'."
|
||||||
}
|
}
|
||||||
|
|
||||||
_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'
|
||||||
|
|
||||||
|
|
@ -1056,8 +1047,8 @@ function all_groups() {
|
||||||
declare -f | metafor group | sort -u
|
declare -f | metafor group | sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
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'
|
||||||
|
|
@ -1070,7 +1061,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