From ac8c049dbf0210dbb58243fb8a20b944f3b24361 Mon Sep 17 00:00:00 2001 From: Sylvester Joosten <sjoosten@anl.gov> Date: Thu, 30 Sep 2021 22:46:46 +0000 Subject: [PATCH] Ps1 preamble (cherry picked from commit bbaee3c7b23a4f8936aa1cf11b8a2b221465253c) --- .gitlab-ci.yml | 2 +- containers/jug/eic-env.sh | 31 ++++++++++++++++++++++++++++++- containers/jug/xl.Dockerfile | 1 + 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 672918b62..5df614e46 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -270,7 +270,7 @@ jug_xl:nightly: - docker build -t ${CI_REGISTRY_IMAGE}/${BUILD_IMAGE}:${NIGHTLY_TAG} -f containers/jug/xl.Dockerfile --build-arg INTERNAL_TAG=${INTERNAL_TAG} - --build-arg JUG_VERSION=nightly-$(date +%Y-%m-%d_%H-%M-%S)-$(git rev-parse HEAD) + --build-arg JUG_VERSION=nightly-$(date +%Y-%m-%d_%H-%M-%S)-${INTERNAL_TAG}-$(git rev-parse HEAD) containers/jug - | PUSH_FLAG="" diff --git a/containers/jug/eic-env.sh b/containers/jug/eic-env.sh index 15a14c41b..9cd6ebebb 100755 --- a/containers/jug/eic-env.sh +++ b/containers/jug/eic-env.sh @@ -6,8 +6,37 @@ for i in /etc/profile.d/*.sh; do fi done -export PS1='eic-shell> \[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +## default PS1 preamble in case we can't find better info +PS1_PREAMBLE='eic-shell> ' +## try to guess who we are +## note: we use sigils for the following cases: +## - no sigil for nightly builds (jug_xl> ) +## - (*) for master builds (jug_xl*> ) +## - (+) for stable (versioned) (jug_xl+> ) +## - (?) for unstable (MR) (jug_xl?> ) +if [ -f /etc/jug_info ]; then + container=$(grep -e 'jug_' /etc/jug_info | tail -n 1 | awk '{print($2);}') + container=${container%:} ## jug_xl + version=$(grep -e 'jug_' /etc/jug_info | tail -n 1 | awk '{print($3);}') + if [ ! -z ${container} ]; then + if [[ $version =~ 'unstable' ]]; then + sigil="?" + elif [[ $version =~ 'testing' ]]; then + sigil="*" + elif [[ $version =~ 'nightly' ]]; then + sigil="" + else # stable + sigil="+" + fi + PS1_PREAMBLE="${container}${sigil}> " + unset sigil + fi + unset version + unset container +fi +export PS1=${PS1_PREAMBLE}'\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33' +unset PS1_PREAMBLE ## redefine ls and less as functions, as this is something we ## can import into our plain bash --norc --noprofile session diff --git a/containers/jug/xl.Dockerfile b/containers/jug/xl.Dockerfile index 30b230be7..12f81b2de 100644 --- a/containers/jug/xl.Dockerfile +++ b/containers/jug/xl.Dockerfile @@ -143,3 +143,4 @@ RUN mkdir -p /opt/campaigns https://eicweb.phy.anl.gov/EIC/campaigns/condor.git \ && git clone -b ${CAMPAIGNS_SLURM_VERSION} --depth 1 \ https://eicweb.phy.anl.gov/EIC/campaigns/slurm.git + -- GitLab