Skip to content

DRAFT: Use XDG Base Directory Specification folder locations #1904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1dfa28a
lib/helpers: first `shellcheck` pass
gaelicWizard Oct 10, 2021
9c77c0f
lib/helpers: fix `_command_exists()`
gaelicWizard Oct 10, 2021
a0a359f
lib/helpers: second `shellcheck` pass
gaelicWizard Oct 10, 2021
5043c78
lib/helpers: `shfmt`
gaelicWizard Oct 16, 2021
7ea6efa
lib/helpers: fix `all_groups()`
gaelicWizard Sep 23, 2021
9c0415c
lib/helpers: cleanup
gaelicWizard Oct 12, 2021
778db5a
lib/helpers: fix `_bash-it-describe()`
gaelicWizard Oct 12, 2021
31bd63f
plugins/ruby: tests on Mac OS X
gaelicWizard Sep 9, 2021
9e2cc9d
lib/search: code style cleanup
gaelicWizard Sep 6, 2021
f7157b1
lib/search: `shellcheck`
gaelicWizard Sep 9, 2021
12385d0
lib/search: fix `_bash-it-flash-term()`
gaelicWizard Oct 10, 2021
b06cd70
lib/search: fix usage statement `_bash-it-search()`
gaelicWizard Sep 19, 2021
512ca41
lib/search: `shfmt`
gaelicWizard Sep 20, 2021
2973434
lib/log: `shellcheck` && `shfmt`
gaelicWizard Oct 14, 2021
7184c49
lib/log: rename `_log_general()`
gaelicWizard Oct 16, 2021
2f52b43
lib/log: function `_bash-it-log-prefix-by-path()`
gaelicWizard Oct 16, 2021
077b2c5
main: Glob for *.bash properly when path contains spaces
gaelicWizard Oct 18, 2021
a71c98e
main: adopt `_bash-it-log-prefix-by-path()`
gaelicWizard Oct 16, 2021
437fd2a
main: simplify flow of lib loader loop
gaelicWizard Oct 16, 2021
08217d7
lib/appearance: `shellcheck` && `shfmt`
gaelicWizard Sep 20, 2021
e3f7f09
lib: delete `appearance.bash`
gaelicWizard Oct 18, 2021
5d130a4
lib/reloader: adopt `_bash-it-log-prefix-by-path()`
gaelicWizard Oct 13, 2021
1506f9a
reloader: `shellcheck` && `shfmt`
gaelicWizard Oct 13, 2021
6684422
lib/preview: `shfmt` && `shellcheck`
gaelicWizard Sep 20, 2021
0b74fcf
uninstall: `shellcheck` && `shfmt`
gaelicWizard Oct 10, 2021
8317ef2
lint: add lib to clean_files.txt
gaelicWizard Oct 13, 2021
070c35a
lib/utilities: XDG_CACHE_HOME
gaelicWizard Sep 20, 2021
68f0cd6
plugins/dirs: use XDG_STATE_HOME
gaelicWizard Sep 19, 2021
5c8ef51
plugin/dirs: `shfmt` && `shellcheck`
gaelicWizard Sep 20, 2021
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
156 changes: 72 additions & 84 deletions bash_it.sh
Original file line number Diff line number Diff line change
@@ -1,61 +1,42 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034
#
# Initialize Bash It
BASH_IT_LOG_PREFIX="core: main: "

# Only set $BASH_IT if it's not already set
if [ -z "${BASH_IT:-}" ]; then
# Setting $BASH to maintain backwards compatibility
export BASH_IT=$BASH
BASH="$(bash -c 'echo $BASH')"
export BASH
BASH_IT_OLD_BASH_SETUP=true
fi
: "${BASH_IT:=${BASH_SOURCE%/*}}"
: "${BASH_IT_CUSTOM:=${BASH_IT}/custom}"
: "${CUSTOM_THEME_DIR:="${BASH_IT_CUSTOM}/themes"}"
# Store the rcfile for later
: "${BASH_IT_BASHRC:=${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}}"

# Load composure first, so we support function metadata
# shellcheck disable=SC1090
source "${BASH_IT}"/vendor/github.com/erichs/composure/composure.sh

# We need to load logging module first as well in order to be able to log
# shellcheck source=./lib/log.bash
source "${BASH_IT}/lib/log.bash"

# We can only log it now
[ -z "${BASH_IT_OLD_BASH_SETUP:-}" ] || _log_warning "BASH_IT variable not initialized, please upgrade your bash-it version and reinstall it!"

# For backwards compatibility, look in old BASH_THEME location
if [ -z "${BASH_IT_THEME:-}" ]; then
_log_warning "BASH_IT_THEME variable not initialized, please upgrade your bash-it version and reinstall it!"
export BASH_IT_THEME="${BASH_THEME:-}"
unset BASH_THEME
fi

# shellcheck source-path=SCRIPTDIR/vendor/github.com/erichs/composure
source "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
# support 'plumbing' metadata
cite _about _param _example _group _author _version
cite about-alias about-plugin about-completion

# libraries, but skip appearance (themes) for now
_log_debug "Loading libraries(except appearance)..."
LIB="${BASH_IT}/lib/*.bash"
APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash"
for _bash_it_config_file in $LIB; do
if [ "$_bash_it_config_file" != "$APPEARANCE_LIB" ]; then
filename=${_bash_it_config_file##*/}
filename=${filename%.bash}
BASH_IT_LOG_PREFIX="lib: ${filename}: "
_log_debug "Loading library file..."
# shellcheck disable=SC1090
source "$_bash_it_config_file"
fi
done
# We need to load logging module early in order to be able to log
# shellcheck source-path=SCRIPTDIR/lib
source "${BASH_IT}/lib/log.bash"

# Load vendors
BASH_IT_LOG_PREFIX="vendor: "
for _bash_it_vendor_init in "${BASH_IT}"/vendor/init.d/*.bash; do
_log_debug "Loading \"$(basename "${_bash_it_vendor_init}" .bash)\"..."
# shellcheck disable=SC1090
source "${_bash_it_vendor_init}"
# We can log now; sanity checks
BASH_IT_LOG_PREFIX="core: main: "
if [[ -d "${BASH}" ]]; then
_log_warning "BASH variable initialized improperly, please upgrade your bash-it version!"
BASH="$(bash -c 'echo $BASH')"
fi

# Load libraries
_log_debug "Loading libraries..."
for _bash_it_lib_file in "${BASH_IT}"/lib/*.bash "${BASH_IT}/vendor/init.d"/*.bash; do
_bash-it-log-prefix-by-path "${_bash_it_lib_file}"
_log_debug "Loading library file..."
# shellcheck source-path=SCRIPTDIR/lib;SCRIPTDIR/vendor/init.d disable=SC1090
source "$_bash_it_lib_file"
done
unset _bash_it_vendor_init
unset _bash_it_lib_file

BASH_IT_LOG_PREFIX="core: main: "
# Load the global "enabled" directory
Expand All @@ -65,95 +46,102 @@ source "${BASH_IT}/scripts/reloader.bash"

# Load enabled aliases, completion, plugins
for file_type in "aliases" "plugins" "completion"; do
# shellcheck source=./scripts/reloader.bash
# shellcheck source-path=SCRIPTDIR/scripts
source "${BASH_IT}/scripts/reloader.bash" "skip" "$file_type"
done

# Load theme, if a theme was set
if [[ -n "${BASH_IT_THEME}" ]]; then
_log_debug "Loading \"${BASH_IT_THEME}\" theme..."
# For backwards compatibility, look in old BASH_THEME location
if [[ -n "${BASH_IT_THEME:="${BASH_THEME:-}"}" ]]; then
if [[ -n "${BASH_THEME:-}" ]]; then
_log_warning "BASH_THEME variable is set, please use BASH_IT_THEME instead!"
unset BASH_THEME
fi

_log_debug "Loading theme: ${BASH_IT_THEME}..."
# Load colors and helpers first so they can be used in base theme
BASH_IT_LOG_PREFIX="themes: colors: "
# shellcheck source=./themes/colors.theme.bash
# shellcheck source-path=SCRIPTDIR/themes
source "${BASH_IT}/themes/colors.theme.bash"
BASH_IT_LOG_PREFIX="themes: githelpers: "
# shellcheck source=./themes/githelpers.theme.bash
# shellcheck source-path=SCRIPTDIR/themes
source "${BASH_IT}/themes/githelpers.theme.bash"
BASH_IT_LOG_PREFIX="themes: p4helpers: "
# shellcheck source=./themes/p4helpers.theme.bash
# shellcheck source-path=SCRIPTDIR/themes
source "${BASH_IT}/themes/p4helpers.theme.bash"
BASH_IT_LOG_PREFIX="themes: command_duration: "
# shellcheck source=./themes/command_duration.theme.bash
# shellcheck source-path=SCRIPTDIR/themes
source "${BASH_IT}/themes/command_duration.theme.bash"
BASH_IT_LOG_PREFIX="themes: base: "
# shellcheck source=./themes/base.theme.bash
# shellcheck source-path=SCRIPTDIR/themes
source "${BASH_IT}/themes/base.theme.bash"

BASH_IT_LOG_PREFIX="lib: appearance: "
# appearance (themes) now, after all dependencies
# shellcheck source=./lib/appearance.bash
source "$APPEARANCE_LIB"
# shellcheck disable=SC1090
if [[ -f "${BASH_IT_THEME}" ]]; then
source "${BASH_IT_THEME}"
elif [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then
source "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash"
elif [[ -f "$BASH_IT/themes/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then
source "$BASH_IT/themes/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash"
fi
else
_log_warning "BASH_IT_THEME variable not initialized, please upgrade your bash-it version!"
fi

BASH_IT_LOG_PREFIX="core: main: "
_log_debug "Loading custom aliases, completion, plugins..."
for file_type in "aliases" "completion" "plugins"; do
if [ -e "${BASH_IT}/${file_type}/custom.${file_type}.bash" ]; then
BASH_IT_LOG_PREFIX="${file_type}: custom: "
_bash_it_custom_file="${BASH_IT}/${file_type}/custom.${file_type}.bash"
if [[ -e "${_bash_it_custom_file}" ]]; then
_bash-it-log-prefix-by-path "${_bash_it_custom_file}"
_log_debug "Loading component..."
# shellcheck disable=SC1090
source "${BASH_IT}/${file_type}/custom.${file_type}.bash"
source "${_bash_it_custom_file}"
fi
done
unset _bash_it_custom_file

# Custom
BASH_IT_LOG_PREFIX="core: main: "
_log_debug "Loading general custom files..."
CUSTOM="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/*.bash ${BASH_IT_CUSTOM:=${BASH_IT}/custom}/**/*.bash"
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: "
for _bash_it_custom_file in "$BASH_IT_CUSTOM"/*.bash "$BASH_IT_CUSTOM"/*/*.bash; do
if [[ -e "${_bash_it_custom_file}" ]]; then
_bash-it-log-prefix-by-path "${_bash_it_custom_file}"
_log_debug "Loading custom file..."
# shellcheck disable=SC1090
source "$_bash_it_config_file"
source "$_bash_it_custom_file"
fi
done
unset _bash_it_custom_file

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

# Adding Support for other OSes
PREVIEW="less"

if [ -s /usr/bin/gloobus-preview ]; then
if [[ -s /usr/bin/gloobus-preview ]]; then
PREVIEW="gloobus-preview"
elif [ -s /Applications/Preview.app ]; then
# shellcheck disable=SC2034
elif [[ -s /Applications/Preview.app ]]; then
PREVIEW="/Applications/Preview.app"
fi

# Load all the Jekyll stuff

if [ -e "$HOME/.jekyllconfig" ]; then
if [[ -e "$HOME/.jekyllconfig" ]]; then
# shellcheck disable=SC1090
. "$HOME/.jekyllconfig"
source "$HOME/.jekyllconfig"
fi

# BASH_IT_RELOAD_LEGACY is set.
# shellcheck disable=SC2139
if ! _command_exists reload && [[ -n "${BASH_IT_RELOAD_LEGACY:-}" ]]; then
case $OSTYPE in
darwin*)
alias reload='source ~/.bash_profile'
;;
*)
alias reload='source ~/.bashrc'
;;
esac
if shopt -q login_shell; then
alias reload="source '${BASH_IT_BASHRC:-$HOME/.bash_profile}'"
else
alias reload="source '${BASH_IT_BASHRC:-$HOME/.bashrc}'"
fi
fi

# Disable trap DEBUG on subshells - https://github.com/Bash-it/bash-it/pull/1040
Expand Down
7 changes: 4 additions & 3 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#
docs/
hooks/
lib/
scripts/

# root files
#
Expand All @@ -26,6 +28,7 @@ bash_it.sh
clean_files.txt
install.sh
lint_clean_files.sh
uninstall.sh

# aliases
#
Expand Down Expand Up @@ -76,9 +79,6 @@ completion/available/vault.completion.bash
completion/available/vuejs.completion.bash
completion/available/wpscan.completion.bash

# libraries
lib/utilities.bash

# plugins
#
plugins/available/alias-completion.plugin.bash
Expand All @@ -88,6 +88,7 @@ plugins/available/basher.plugin.bash
plugins/available/blesh.plugin.bash
plugins/available/cmd-returned-notify.plugin.bash
plugins/available/direnv.plugin.bash
plugins/available/dirs.plugin.bash
plugins/available/docker-machine.plugin.bash
plugins/available/git.plugin.bash
plugins/available/go.plugin.bash
Expand Down
19 changes: 0 additions & 19 deletions lib/appearance.bash

This file was deleted.

Loading