diff options
Diffstat (limited to 'bin/install.sh')
-rwxr-xr-x | bin/install.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/install.sh b/bin/install.sh new file mode 100755 index 0000000..b6d6bde --- /dev/null +++ b/bin/install.sh | |||
@@ -0,0 +1,30 @@ | |||
1 | #! /usr/bin/env bash | ||
2 | |||
3 | set -e | ||
4 | |||
5 | # Default settings | ||
6 | SETTING_DIR=${SETTING_DIR:-~/helper} | ||
7 | REPO=${REPO:-typebrook/helper} | ||
8 | REMOTE=${REMOTE:-https://github.com/${REPO}.git} | ||
9 | BRANCH=${BRANCH:-dev} | ||
10 | RCFILE=${RCFILE:-~/.$(basename $SHELL)rc} | ||
11 | |||
12 | if [ ! -d $SETTING_DIR ]; then | ||
13 | git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || { | ||
14 | error "git clone of helper repo failed" | ||
15 | exit 1 | ||
16 | } | ||
17 | fi | ||
18 | |||
19 | # Write initial commands into .bashrc or .zshrc | ||
20 | sed -i'.bak' "\^# $REPO^, /^$/ d" $RCFILE | ||
21 | cat >>$RCFILE <<EOF | ||
22 | |||
23 | # $REPO | ||
24 | export SETTING_DIR=$SETTING_DIR | ||
25 | source \$SETTING_DIR/bin/init/load-settings.sh | ||
26 | EOF | ||
27 | |||
28 | cd "$SETTING_DIR" || exit 1 | ||
29 | git swapprotocol | ||
30 | make | ||