env.sh: $0 -> $BASH_SOURCE (to allow sourcing the file)

and set the prompt in `env.sh bash`
This commit is contained in:
Ștefan Talpalaru 2019-08-23 18:55:16 +02:00
parent bf10b1b72e
commit 9397da232f
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9

View File

@ -11,7 +11,7 @@
## get native Windows paths on Mingw
#uname | grep -qi mingw && PWD_CMD="pwd -W"
export REL_PATH="$(dirname $0)"
export REL_PATH="$(dirname $BASH_SOURCE)"
export ABS_PATH="$(cd ${REL_PATH}; pwd)"
# do we still need this?
#ABS_PATH_NATIVE="$(cd ${REL_PATH}; ${PWD_CMD})"
@ -47,6 +47,13 @@ add_submodule() {
}
export -f add_submodule
# can't use "exec" here if we're getting function names as params
"$@"
if [[ $# == 1 && $1 == "bash" ]]; then
# the only way to change PS1 in a child shell, apparently
# (we're not getting the original PS1 value in here, so set a complete and nice prompt)
export PS1="[Nimbus env] \[\033[0;31m\]\l \[\033[1;33m\]\d \[\033[1;36m\]\t \[\033[0;32m\]|\w|\[\033[0m\]\n\u\$ "
exec "$1" --login --noprofile
else
# can't use "exec" here if we're getting function names as params
"$@"
fi