Skip to content

Commit

Permalink
install: use .bashrc and notify user
Browse files Browse the repository at this point in the history
The logic to guess whether to use `.bash_profile` or `.bashrc` was buggy and wrong. Just use `.bashrc` and either automatically fill in a `.bash_profile`, or notify the user that they need to edit their `.bash_profile`.
  • Loading branch information
gaelicWizard committed Feb 8, 2022
1 parent ebc1d03 commit e6ac356
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ function _bash-it_backup_new() {

# Back up existing profile and append bash-it templates at the end
function _bash-it_backup_append() {
local profile_strings=('if [[ -f ~/.bashrc ]]; then' 'source ~/.bashrc' 'fi')
_bash-it_backup
(sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE"
if [[ ! -f ~/.bash_profile && ! -f ~/.bash_login && ! -f ~/.profile ]]; then
printf '%s\n\t%s\n%s\n' "${profile_strings[@]}" > ~/.bash_profile
else
printf '\e[0;33m%s\n\t%s\n\t\t%s\n\t%s\n\e[0m' "You may need to update your ~/.bash_profile (or ~/.profile) to source your ~/.bashrc:" "${profile_strings[@]}"
fi
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
}

Expand Down Expand Up @@ -186,14 +192,7 @@ fi

BASH_IT="$(cd "${BASH_SOURCE%/*}" && pwd)"

case $OSTYPE in
darwin*)
CONFIG_FILE=.bash_profile
;;
*)
CONFIG_FILE=.bashrc
;;
esac
CONFIG_FILE=.bashrc

BACKUP_FILE=$CONFIG_FILE.bak
echo "Installing bash-it"
Expand All @@ -205,13 +204,13 @@ fi
export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=''
# Load dependencies for enabling components
# shellcheck disable=SC1090
source "${BASH_IT}"/vendor/github.com/erichs/composure/composure.sh
# shellcheck source=./lib/utilities.bash
source "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
cite _about _param _example _group _author _version
# shellcheck source-path=SCRIPTDIR/lib
source "$BASH_IT/lib/utilities.bash"
# shellcheck source=./lib/log.bash
# shellcheck source-path=SCRIPTDIR/lib
source "${BASH_IT}/lib/log.bash"
cite _about _param _example _group _author _version
# shellcheck source=./lib/helpers.bash
# shellcheck source-path=SCRIPTDIR/lib
source "$BASH_IT/lib/helpers.bash"

if [[ -n $interactive && -z "${silent}" ]]; then
Expand Down

0 comments on commit e6ac356

Please sign in to comment.