diff options
Diffstat (limited to 'bin/install.sh')
-rwxr-xr-x | bin/install.sh | 30 |
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} | |||
7 | REPO=${REPO:-typebrook/helper} | 7 | REPO=${REPO:-typebrook/helper} |
8 | REMOTE=${REMOTE:-https://github.com/${REPO}.git} | 8 | REMOTE=${REMOTE:-https://github.com/${REPO}.git} |
9 | BRANCH=${BRANCH:-dev} | 9 | BRANCH=${BRANCH:-dev} |
10 | RCFILE=${RCFILE:-~/.$(basename $SHELL)rc} | 10 | COMMENT_IN_RCFILE="# $REPO: source custom shell settings" |
11 | PROFILE=profile.sh | ||
11 | 12 | ||
13 | case "$(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 | ;; | ||
20 | esac | ||
21 | |||
22 | # If ~/helper doesn't exist, do git clone | ||
12 | if [ ! -d $SETTING_DIR ]; then | 23 | if [ ! -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 | } |
17 | fi | 28 | fi |
18 | 29 | ||
19 | # Write initial commands into .bashrc or .zshrc | 30 | # Write initial commands into .bashrc or .zshrc |
20 | sed -i'.bak' "\^# $REPO^, /^$/ d" $RCFILE | 31 | sed -i "\^$COMMENT_IN_RCFILE^, /^$/ d" $RCFILE |
21 | cat >>$RCFILE <<EOF | 32 | cat >>$RCFILE <<EOF |
22 | 33 | ||
23 | # $REPO | 34 | $COMMENT_IN_RCFILE |
24 | export SETTING_DIR=$SETTING_DIR | 35 | export SETTING_DIR=$SETTING_DIR |
25 | source \$SETTING_DIR/bin/init/load-settings.sh | 36 | source \$SETTING_DIR/$PROFILE |
37 | |||
26 | EOF | 38 | EOF |
27 | 39 | ||
40 | echo Add profile into $RCFILE | ||
28 | cd "$SETTING_DIR" || exit 1 | 41 | cd "$SETTING_DIR" || exit 1 |
29 | make | 42 | make |
30 | EOF | ||