diff --git a/CHANGELOG.md b/CHANGELOG.md index 4317cb8e76e1cda8030be42e1bb3ce8806865e25..14391c7f460f468b6d0bddf8755de83d492f4193 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * * Tests that the correct version is loaded * * Tests that elementary patching/building works as expected * Added consistency check between e3 environment variables and path to `iocsh.bash`. `iocsh.bash` will abort if these are not consistent. +* Add e3 version infomation to the shell prompt ### Bugfixes * `iocsh.bash --help` (and variants) no longer loads tries to load `env.sh`. diff --git a/require-ess/tools/setE3Env.bash b/require-ess/tools/setE3Env.bash index dea3f30df14af1863eff6d93cfb05610aad8a4af..154f3d1f53e924381bf206f6d7dcf8514a7c791b 100644 --- a/require-ess/tools/setE3Env.bash +++ b/require-ess/tools/setE3Env.bash @@ -25,6 +25,15 @@ # # +if [[ "$0" == "${BASH_SOURCE[0]}" ]]; then + echo + echo "##################################################" + echo "$0 is NOT properly sourced !" + echo "##################################################" + echo + exit 1 +fi + # the following function drop_from_path was copied from # the ROOT build system in ${ROOTSYS}/bin/, and modified # a little to return its result @@ -336,3 +345,20 @@ export LD_LIBRARY_PATH source "${SRC_PATH}"/iocsh_complete.bash print_env "$1" + +BASE_version="${EPICS_BASE##*/base-}" +E3_ENV_INFO="(${BASE_version}-${E3_REQUIRE_VERSION})" +NEW_E3_PS="${E3_ENV_INFO}\[\033[33m\]\u\[\033[m\]@\[\033[33;1m\]\w\[\033[m\]\$ " + +if [ -z "$E3_ENV_ON" ]; then + if [ -z "$PS1" ]; then + export E3_ENV_ON="ON" + export PS1="${NEW_E3_PS}" + else + export E3_ENV_ON="ON" + export PS1="${E3_ENV_INFO}${PS1}" + fi +else + PS_TMP=${PS1#*\)} + export PS1="${E3_ENV_INFO}${PS_TMP}" +fi