From 72efdaaa43aabf3c4d261cc78b48e6e46c7beab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?= Date: Sat, 11 Apr 2020 12:42:54 +0800 Subject: [PATCH] more fix --- scripts/apply.sh | 26 ++++---------------------- scripts/functions.sh | 12 ++++++++++++ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/scripts/apply.sh b/scripts/apply.sh index b48a3b057..558a26890 100755 --- a/scripts/apply.sh +++ b/scripts/apply.sh @@ -1,29 +1,11 @@ #!/usr/bin/env bash -# get base dir regardless of execution location -# resolve shell-specifics -case "$(echo "$SHELL" | sed -E 's|/usr(/local)?||g')" in - "/bin/zsh") - RCPATH="$HOME/.zshrc" - SOURCE="${BASH_SOURCE[0]:-${(%):-%N}}" - ;; - *) - RCPATH="$HOME/.bashrc" - if [[ -f "$HOME/.bash_aliases" ]]; then - RCPATH="$HOME/.bash_aliases" - fi - SOURCE="${BASH_SOURCE[0]}" - ;; -esac # get base dir regardless of execution location +basedir=$1 -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -. $(dirname $SOURCE)/init.sh -PS1="$" +source "$basedir/scripts/functions.sh" + +. $basedir/functions.sh paperVer=$(cat current-paper) gpgsign="$(git config commit.gpgsign || echo "false")" diff --git a/scripts/functions.sh b/scripts/functions.sh index cd689eb7c..190729307 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -102,3 +102,15 @@ function containsElement { done return 1 } + +function bashColor { +if [ $2 ]; then + echo -e "\e[$1;$2m" +else + echo -e "\e[$1m" +fi +} +function bashColorReset { + echo -e "\e[m" +} +