Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
bats-test:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, macos-10.15, macos-11.0]
os: [ubuntu-20.04, ubuntu-18.04, macos-10.15, macos-11.0]

runs-on: ${{ matrix.os }}

Expand Down
6 changes: 0 additions & 6 deletions .shellcheckrc

This file was deleted.

3 changes: 2 additions & 1 deletion bash_it.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ for _bash_it_config_file in $CUSTOM; do
if [ -e "${_bash_it_config_file}" ]; then
filename=$(basename "${_bash_it_config_file}")
filename=${filename%*.bash}
# shellcheck disable=SC2034
BASH_IT_LOG_PREFIX="custom: $filename: "
_log_debug "Loading custom file..."
# shellcheck disable=SC1090
Expand All @@ -122,7 +123,7 @@ for _bash_it_config_file in $CUSTOM; do
done

unset _bash_it_config_file
if [[ "${PROMPT:-}" ]]; then
if [[ -n "${PROMPT:-}" ]]; then
export PS1="\[""$PROMPT""\]"
fi

Expand Down
14 changes: 7 additions & 7 deletions completion/available/composer.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ cite "about-completion"
about-completion "composer completion"

function __composer_completion() {
local cur coms opts com
local cur coms opts com words
COMPREPLY=()
_get_comp_words_by_ref -n : cur words

# lookup for command
for word in "${words[@]:1}"; do
if [[ $word != -* ]]; then
com=$word
if [[ "${word}" != -* ]]; then
com="${word}"
break
fi
done
Expand All @@ -19,7 +19,7 @@ function __composer_completion() {
if [[ ${cur} == --* ]]; then
opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir"

case "$com" in
case "${com}" in
about)
opts="${opts} "
;;
Expand Down Expand Up @@ -109,18 +109,18 @@ function __composer_completion() {

# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
__ltrim_colon_completions "$cur"
__ltrim_colon_completions "${cur}"

return 0
fi

# completing for a command
if [[ "$cur" == "$com" ]]; then
if [[ "${cur}" == "${com}" ]]; then
coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate"

# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${coms}" -- "${cur}"))
__ltrim_colon_completions "$cur"
__ltrim_colon_completions "${cur}"

return 0
fi
Expand Down
2 changes: 2 additions & 0 deletions completion/available/dart.completion.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# shellcheck shell=bash

__dart_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword)

local HELP="--help -h"
Expand Down
2 changes: 2 additions & 0 deletions completion/available/dmidecode.completion.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# shellcheck shell=bash

function __dmidecode_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword)

case $prev in
Expand Down
12 changes: 8 additions & 4 deletions completion/available/knife.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ _KAC_is_file_newer_than() {
_KAC_regen_cache() {
local CACHE_NAME=$1
local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
# shellcheck disable=SC2155
local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX")
shift 1
# discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated
Expand All @@ -66,6 +67,7 @@ _KAC_get_command_from_cache_name() {
# otherwise it waits for the cache to be generated
# in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable
# for obvious reason, do NOT call that in a sub-shell (in particular, no piping)
# shellcheck disable=SC2155
_KAC_get_and_regen_cache() {
# the cache name can't have space in it
local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@")
Expand Down Expand Up @@ -100,7 +102,7 @@ _KAC_clean_cache() {

# perform a cache cleaning when loading this file
# On big systems this could baloon up to a 30 second run or more, so not enabling by default.
[[ "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache
[[ -n "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache

#####################################
### End of cache helper functions ###
Expand All @@ -118,7 +120,7 @@ _KAC_get_current_base_command() {
local PREVIOUS="knife"
local I=1
local CURRENT
while [ $I -le "$COMP_CWORD" ]; do
while [[ "${I}" -le "${COMP_CWORD}" ]]; do
# command words are all lower-case
echo "${COMP_WORDS[$I]}" | grep -E "^[a-z]+$" > /dev/null || break
CURRENT="$PREVIOUS ${COMP_WORDS[$I]}"
Expand All @@ -127,12 +129,13 @@ _KAC_get_current_base_command() {
I=$((I + 1))
done
_KAC_CURRENT_COMMAND=$PREVIOUS
[ $I -le "$COMP_CWORD" ] && _KAC_CURRENT_COMMAND_NB_WORDS=$I
[[ "${I}" -le "${COMP_CWORD}" ]] && _KAC_CURRENT_COMMAND_NB_WORDS="${I}"
}

# searches the position of the currently completed argument in the current base command
# (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...)
# assumes the current base command is complete
# shellcheck disable=SC2155
_KAC_get_current_arg_position() {
local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1))
local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH")
Expand All @@ -150,10 +153,11 @@ _KAC_get_current_arg_position() {
_knife() {
_KAC_get_and_regen_cache _KAC_knife_commands
local RAW_LIST ITEM REGEN_CMD ARG_POSITION
# shellcheck disable=SC2034
COMREPLY=()
# get correct command & arg pos
_KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$((COMP_CWORD + 1))
RAW_LIST=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH" | cut -d ' ' -f $ARG_POSITION | uniq)
RAW_LIST=$(grep -E "^${_KAC_CURRENT_COMMAND}" "${_KAC_CACHE_PATH}" | cut -d ' ' -f "${ARG_POSITION}" | uniq)

# we need to process that raw list a bit, most notably for placeholders
# NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc)
Expand Down
2 changes: 2 additions & 0 deletions completion/available/ngrok.completion.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# shellcheck shell=bash

__ngrok_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword)

local BASE_NO_CONF="--log --log-format --log-level --help"
Expand Down
2 changes: 2 additions & 0 deletions completion/available/notify-send.completion.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# shellcheck shell=bash

function __notify-send_completions() {
# shellcheck disable=SC2155
local curr=$(_get_cword)
# shellcheck disable=SC2155
local prev=$(_get_pword)

case $prev in
Expand Down
16 changes: 9 additions & 7 deletions completion/available/sdkman.completion.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# shellcheck shell=bash
_sdkman_complete() {

function _sdkman_complete() {
local CANDIDATES
local CANDIDATE_VERSIONS
local SDKMAN_CANDIDATES_CSV="${SDKMAN_CANDIDATES_CSV:-}"

COMPREPLY=()

Expand All @@ -10,7 +12,7 @@ _sdkman_complete() {
elif [ "$COMP_CWORD" -eq 2 ]; then
case "${COMP_WORDS[COMP_CWORD - 1]}" in
"install" | "i" | "uninstall" | "rm" | "list" | "ls" | "use" | "u" | "default" | "d" | "home" | "h" | "current" | "c" | "upgrade" | "ug")
CANDIDATES=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ')
CANDIDATES="${SDKMAN_CANDIDATES_CSV//,/${IFS:0:1}}"
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATES" -- "${COMP_WORDS[COMP_CWORD]}")
;;
"env")
Expand Down Expand Up @@ -46,17 +48,17 @@ _sdkman_complete() {
return 0
}

_sdkman_candidate_local_versions() {
function _sdkman_candidate_local_versions() {

CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1")

}

_sdkman_candidate_all_versions() {
function _sdkman_candidate_all_versions() {

candidate="$1"
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate")
if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then
if [[ "${SDKMAN_OFFLINE_MODE:-false}" == "true" ]]; then
CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS
else
# sdkman has a specific output format for Java candidate since
Expand All @@ -70,12 +72,12 @@ _sdkman_candidate_all_versions() {
# "+" - local version
# "*" - installed
# ">" - currently in use
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort | uniq -u) "
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort -u) "
fi

}

__sdkman_cleanup_local_versions() {
function __sdkman_cleanup_local_versions() {

__sdkman_build_version_csv "$1" | tr ',' ' '

Expand Down
2 changes: 2 additions & 0 deletions completion/available/vuejs.completion.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# shellcheck shell=bash

__vuejs_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword)

case $prev in
Expand Down
2 changes: 1 addition & 1 deletion hooks/dot-bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ for file in "$@"; do
fi
done

exit $exit_code
exit "${exit_code:-0}"
2 changes: 1 addition & 1 deletion hooks/dot-sh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ for file in "$@"; do
fi
done

exit $exit_code
exit "${exit_code:-0}"
28 changes: 14 additions & 14 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ function _bash-it_check_for_backup() {
fi
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2

if ! [[ $overwrite_backup ]]; then
while ! [[ $silent ]]; do
if [[ -z "${overwrite_backup}" ]]; then
while [[ -z "${silent}" ]]; do
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
case $RESP in
[yY])
Expand All @@ -100,9 +100,9 @@ function _bash-it_check_for_backup() {
esac
done
fi
if ! [[ $overwrite_backup ]]; then
if [[ -z "${overwrite_backup}" ]]; then
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
if [[ $silent ]]; then
if [[ -n "${silent}" ]]; then
echo -e "\033[91mUse \"-f\" flag to force overwrite of backup.\033[m"
fi
exit 1
Expand All @@ -114,8 +114,8 @@ function _bash-it_check_for_backup() {
function _bash-it_modify_config_files() {
_bash-it_check_for_backup

if ! [[ $silent ]]; then
while ! [[ $append_to_config ]]; do
if [[ -z "${silent}" ]]; then
while [[ -z "${append_to_config}" ]]; do
read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice
case $choice in
[yY])
Expand All @@ -131,7 +131,7 @@ function _bash-it_modify_config_files() {
esac
done
fi
if [[ $append_to_config ]]; then
if [[ -n "${append_to_config}" ]]; then
# backup/append
_bash-it_backup_append
else
Expand Down Expand Up @@ -174,12 +174,12 @@ done

shift $((OPTIND - 1))

if [[ $silent ]] && [[ $interactive ]]; then
if [[ -n "${silent}" && -n "${interactive}" ]]; then
echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m"
exit 1
fi

if [[ $no_modify_config ]] && [[ $append_to_config ]]; then
if [[ -n "${no_modify_config}" && -n "${append_to_config}" ]]; then
echo -e "\033[91mOptions --no-modify-config and --append-to-config are mutually exclusive. Please choose one or the other.\033[m"
exit 1
fi
Expand All @@ -197,7 +197,7 @@ esac

BACKUP_FILE=$CONFIG_FILE.bak
echo "Installing bash-it"
if ! [[ $no_modify_config ]]; then
if [[ -z "${no_modify_config}" ]]; then
_bash-it_modify_config_files
fi

Expand All @@ -212,10 +212,10 @@ cite _about _param _example _group _author _version
# shellcheck source=./lib/helpers.bash
source "$BASH_IT/lib/helpers.bash"

if [[ $interactive ]] && ! [[ $silent ]]; then
if [[ -n $interactive && -z "${silent}" ]]; then
for type in "aliases" "plugins" "completion"; do
echo -e "\033[0;32mEnabling $type\033[0m"
_bash-it_load_some $type
echo -e "\033[0;32mEnabling ${type}\033[0m"
_bash-it_load_some "$type"
done
else
echo ""
Expand All @@ -230,7 +230,7 @@ fi
echo ""
echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m"
# shellcheck disable=SC2086
echo -e "\033[0;32mTo start using it, open a new tab or 'source "$HOME/$CONFIG_FILE"'.\033[0m"
echo -e "\033[0;32mTo start using it, open a new tab or 'source "~/$CONFIG_FILE"'.\033[0m"
echo ""
echo "To show the available aliases/completions/plugins, type one of the following:"
echo " bash-it show aliases"
Expand Down
Empty file modified lib/helpers.bash
100755 → 100644
Empty file.
Empty file modified lib/log.bash
100755 → 100644
Empty file.
Empty file modified lib/search.bash
100755 → 100644
Empty file.
Empty file modified lib/utilities.bash
100755 → 100644
Empty file.
Loading