install: use `.bashrc` and notify user
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`.pull/2039/head
parent
3a778072db
commit
e888ddf953
27
install.sh
27
install.sh
|
|
@ -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 ~/.profile ]]; then' 'source ~/.profile' 'fi' '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 ]]; then
|
||||
printf '%s\n\t%s\n%s\n%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\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"
|
||||
}
|
||||
|
||||
|
|
@ -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"
|
||||
|
|
@ -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/lib/utilities.bash"
|
||||
# shellcheck source=./lib/log.bash
|
||||
source "${BASH_IT}/lib/log.bash"
|
||||
source "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
|
||||
cite _about _param _example _group _author _version
|
||||
# shellcheck source=./lib/helpers.bash
|
||||
# shellcheck source-path=SCRIPTDIR/lib
|
||||
source "$BASH_IT/lib/utilities.bash"
|
||||
# shellcheck source-path=SCRIPTDIR/lib
|
||||
source "${BASH_IT}/lib/log.bash"
|
||||
# shellcheck source-path=SCRIPTDIR/lib
|
||||
source "$BASH_IT/lib/helpers.bash"
|
||||
|
||||
if [[ -n $interactive && -z "${silent}" ]]; then
|
||||
|
|
|
|||
|
|
@ -8,15 +8,7 @@ function local_setup() {
|
|||
|
||||
function local_setup_file() {
|
||||
# Determine which config file to use based on OS.
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
export BASH_IT_CONFIG_FILE=.bash_profile
|
||||
;;
|
||||
*)
|
||||
export BASH_IT_CONFIG_FILE=.bashrc
|
||||
;;
|
||||
esac
|
||||
# don't load any libraries as the tests here test the *whole* kit
|
||||
export BASH_IT_CONFIG_FILE=.bashrc
|
||||
}
|
||||
|
||||
@test "install: verify that the install script exists" {
|
||||
|
|
|
|||
Loading…
Reference in New Issue