forked from brujoand/sbp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·29 lines (24 loc) · 963 Bytes
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /usr/bin/env bash
base_path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
bashrc_path="$HOME"/.bashrc
if [[ ! -f "$HOME"/.config/sbp ]]; then
echo "SBP: Adding default config to $HOME/.config/sbp/sbp.conf"
mkdir -p "$HOME/.config/sbp"
cp "$base_path"/helpers/defaults.bash "$HOME/.config/sbp/sbp.conf"
else
echo "SBP: Found config at $HOME/.sbp"
fi
if ! grep -qE '^sbp_path=*' "$bashrc_path"; then
echo "SBP: adding sbp_path=${base_path} to ~/.bashrc"
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
echo "SBP: adding 'source ${base_path}/sbp.bash' to ~/.bashrc"
echo "source ${base_path}/sbp.bash" >> "$bashrc_path"
else
echo "${base_path}/sbp.bash has already been set to be sourced"
fi
echo "SBP: You'll have to reload bash or source ~/.bashrc for changes to take effect"