Skip to content

Commit

Permalink
Merge pull request #2067 from gaelicWizard/BASH_IT_BASHRC
Browse files Browse the repository at this point in the history
lib/helpers: eliminate assumptions about login shells
  • Loading branch information
NoahGorny committed Jan 29, 2022
2 parents 7e79212 + c08267e commit 1d6f4d7
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions lib/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -654,30 +654,18 @@ function _bash-it-restart() {
_about 'restarts the shell in order to fully reload it'
_group 'lib'

local saved_pwd="${PWD}" init_file
local saved_pwd="${PWD}" init_file="${BASH_IT_BASHRC:-${HOME?}/.bashrc}"

if shopt -q login_shell; then
init_file=.bash_profile
else
init_file=.bashrc
fi
exec "${0/-/}" --rcfile <(echo "source \"$HOME/$init_file\"; cd \"$saved_pwd\"")
exec "${0/-/}" --rcfile <(echo "source \"${init_file}\"; cd \"$saved_pwd\"")
}

function _bash-it-reload() {
_about 'reloads a profile file'
_group 'lib'

pushd "${BASH_IT?}" > /dev/null || return

# shellcheck disable=SC1090
if shopt -q login_shell; then
# shellcheck source-path=$HOME
source ~/.bash_profile
else
# shellcheck source-path=$HOME
source ~/.bashrc
fi
source "${BASH_IT_BASHRC:-${HOME?}/.bashrc}"
popd > /dev/null || return
}

Expand Down

0 comments on commit 1d6f4d7

Please sign in to comment.