Skip to content
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

install: tell users to source bashrc in bash_profile if required #49

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ case :$shell:
*bash*) echo "${BLUE}> echo 'eval \"\$(savvy init bash)\"' >> ~/.bashrc${RESET}";;
esac


## for bash check if .bash_profile exists and if the user has sourced bashrc inside it
BASHRC="$HOME/.bashrc"
BASH_PROFILE="$HOME/.bash_profile"
if [ "$shell" = "bash" ]; then
if [ -f "$BASH_PROFILE" ]; then
# Look for lines that either use source /path/to/.bashrc or . /path/to/.bashrc, accounting for potential spaces.
# The command following if is executed, and if its exit status is 0 (which indicates success), the then branch is executed.
if ! grep -qE "^\s*(source|\.)\s*(.+\.bashrc)" "$BASH_PROFILE"; then
echo "${BLUE}> echo 'source ~/.bashrc' >> ~/.bash_profile${RESET}"
fi
fi
fi




echo "${BLUE}> source ~/.${shell}rc # to pick up the new changes${RESET}"
echo
echo "Run 'savvy help' to learn more or checkout our docs at https://github.com/getsavvyinc/savvy-cli"
Expand Down