Skip to content

Commit

Permalink
Simplify the install checker
Browse files Browse the repository at this point in the history
  • Loading branch information
brujoand committed Dec 17, 2023
1 parent e307fba commit dad9e45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
base_path=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
bashrc_path="$HOME"/.bashrc

if ! grep -qE '^SBP_PATH=*' "$bashrc_path"; then
if [[ -z "$SBP_PATH" ]]; then
echo "SBP: adding sbp_path=${base_path} to ~/.bashrc"
echo "SBP_PATH=${base_path}" >>"$bashrc_path"
echo "SBP_PATH=${base_path}" >> "$bashrc_path"
else
# shellcheck disable=SC2154
echo "SBP: sbp_path has already been set to '$SBP_PATH'"
fi

if ! grep -qE "^(source|.) ${base_path}" "$bashrc_path"; then
if [[ -z "$SBP_SOURCED" ]]; then
echo "SBP: adding 'source ${base_path}/sbp.bash' to ~/.bashrc"
echo "source ${base_path}/sbp.bash" >>"$bashrc_path"
echo "source ${base_path}/sbp.bash" >> "$bashrc_path"
else
echo "${base_path}/sbp.bash has already been set to be sourced"
fi
Expand Down
1 change: 1 addition & 0 deletions sbp.bash
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ _sbp_pre_exec() {
PS0='$(_sbp_pre_exec)'

[[ $PROMPT_COMMAND =~ _sbp_set_prompt ]] || PROMPT_COMMAND="_sbp_set_prompt${PROMPT_COMMAND:+;}$PROMPT_COMMAND"
SBP_SOURCED=1

0 comments on commit dad9e45

Please sign in to comment.