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, 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
3set -e
4
5# Default settings
6SETTING_DIR=${SETTING_DIR:-~/helper}
7REPO=${REPO:-typebrook/helper}
8REMOTE=${REMOTE:-https://github.com/${REPO}.git}
9BRANCH=${BRANCH:-dev}
10RCFILE=${RCFILE:-~/.$(basename $SHELL)rc}
11
12if [ ! -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 }
17fi
18
19# Write initial commands into .bashrc or .zshrc
20sed -i'.bak' "\^# $REPO^, /^$/ d" $RCFILE
21cat >>$RCFILE <<EOF
22
23# $REPO
24export SETTING_DIR=$SETTING_DIR
25source \$SETTING_DIR/bin/init/load-settings.sh
26EOF
27
28cd "$SETTING_DIR" || exit 1
29git swapprotocol
30make