aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/install.sh')
-rwxr-xr-xbin/install.sh30
1 files changed, 21 insertions, 9 deletions
diff --git a/bin/install.sh b/bin/install.sh
index cfc13d3..94f23e5 100755
--- a/bin/install.sh
+++ b/bin/install.sh
@@ -7,24 +7,36 @@ SETTING_DIR=${SETTING_DIR:-~/helper}
7REPO=${REPO:-typebrook/helper} 7REPO=${REPO:-typebrook/helper}
8REMOTE=${REMOTE:-https://github.com/${REPO}.git} 8REMOTE=${REMOTE:-https://github.com/${REPO}.git}
9BRANCH=${BRANCH:-dev} 9BRANCH=${BRANCH:-dev}
10RCFILE=${RCFILE:-~/.$(basename $SHELL)rc} 10COMMENT_IN_RCFILE="# $REPO: source custom shell settings"
11PROFILE=profile.sh
11 12
13case "$(basename $SHELL)" in
14 bash) RCFILE=~/.bashrc
15 ;;
16 zsh) RCFILE=~/.config/zsh/.zshrc
17 ;;
18 *) echo Current shell is not bash or zsh; exit 1;
19 ;;
20esac
21
22# If ~/helper doesn't exist, do git clone
12if [ ! -d $SETTING_DIR ]; then 23if [ ! -d $SETTING_DIR ]; then
13 git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || { 24 git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || {
14 error "git clone of helper repo failed" 25 error "git clone of helper repo failed"
15 exit 1 26 exit 1
16 } 27 }
17fi 28fi
18 29
19# Write initial commands into .bashrc or .zshrc 30# Write initial commands into .bashrc or .zshrc
20sed -i'.bak' "\^# $REPO^, /^$/ d" $RCFILE 31sed -i "\^$COMMENT_IN_RCFILE^, /^$/ d" $RCFILE
21cat >>$RCFILE <<EOF 32cat >>$RCFILE <<EOF
22 33
23# $REPO 34$COMMENT_IN_RCFILE
24export SETTING_DIR=$SETTING_DIR 35export SETTING_DIR=$SETTING_DIR
25source \$SETTING_DIR/bin/init/load-settings.sh 36source \$SETTING_DIR/$PROFILE
37
26EOF 38EOF
27 39
40echo Add profile into $RCFILE
28cd "$SETTING_DIR" || exit 1 41cd "$SETTING_DIR" || exit 1
29make 42make
30EOF