This commit is contained in:
ㄗㄠˋ ㄑㄧˊ
2020-04-11 12:42:54 +08:00
parent e538e89116
commit 72efdaaa43
2 changed files with 16 additions and 22 deletions

View File

@@ -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")"

View File

@@ -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"
}