From 59de29d5164d245dda1608f5e14cf4e1c981ad3e Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 25 Jun 2024 23:09:03 +0800 Subject: Update --- bin/install.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'bin/install.sh') 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} REPO=${REPO:-typebrook/helper} REMOTE=${REMOTE:-https://github.com/${REPO}.git} BRANCH=${BRANCH:-dev} -RCFILE=${RCFILE:-~/.$(basename $SHELL)rc} +COMMENT_IN_RCFILE="# $REPO: source custom shell settings" +PROFILE=profile.sh +case "$(basename $SHELL)" in + bash) RCFILE=~/.bashrc + ;; + zsh) RCFILE=~/.config/zsh/.zshrc + ;; + *) echo Current shell is not bash or zsh; exit 1; + ;; +esac + +# If ~/helper doesn't exist, do git clone if [ ! -d $SETTING_DIR ]; then - git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || { - error "git clone of helper repo failed" - exit 1 - } + git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || { + error "git clone of helper repo failed" + exit 1 + } fi # Write initial commands into .bashrc or .zshrc -sed -i'.bak' "\^# $REPO^, /^$/ d" $RCFILE +sed -i "\^$COMMENT_IN_RCFILE^, /^$/ d" $RCFILE cat >>$RCFILE <