From 835571516b6f27170a586ce7fa2669d0fe9d4cc8 Mon Sep 17 00:00:00 2001 From: Dharhas Pothina Date: Wed, 6 Jul 2022 16:21:45 -0500 Subject: [PATCH] Tweak bashrc (#1363) * force color prompt * add colorized bash prompt with git and conda info * Increase timeout for ssh test Co-authored-by: iameskild --- .../services/jupyterhub/files/skel/.bashrc | 32 ++++++++++++++++++- tests_deployment/test_jupyterhub_ssh.py | 10 +++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/files/skel/.bashrc b/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/files/skel/.bashrc index 3d247ed87..3c863e322 100644 --- a/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/files/skel/.bashrc +++ b/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/files/skel/.bashrc @@ -46,7 +46,7 @@ esac # uncomment for a colored prompt, if the terminal has the capability; turned # off by default to not distract the user: the focus in a terminal window # should be on the output of commands, not on the prompt -#force_color_prompt=yes +force_color_prompt=yes if [ -n "$force_color_prompt" ]; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then @@ -120,3 +120,33 @@ if ! shopt -oq posix; then fi . /opt/conda/etc/profile.d/conda.sh && conda activate base + +# add nicer bash prompt +conda config --set changeps1 True + +parse_git_branch() { + git branch --color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/' +} + +BASE03=$(tput setaf 234) +BASE02=$(tput setaf 235) +BASE01=$(tput setaf 240) +BASE00=$(tput setaf 241) +BASE0=$(tput setaf 244) +BASE1=$(tput setaf 245) +BASE2=$(tput setaf 254) +BASE3=$(tput setaf 230) +YELLOW=$(tput setaf 136) +ORANGE=$(tput setaf 166) +RED=$(tput setaf 160) +MAGENTA=$(tput setaf 125) +VIOLET=$(tput setaf 61) +BLUE=$(tput setaf 33) +CYAN=$(tput setaf 37) +GREEN=$(tput setaf 64) +BOLD=$(tput bold) +RESET=$(tput sgr0) + +NAME=`whoami | cut -d'@' -f1` + +PS1="\[$CYAN\]$NAME:\w\[$RESET\]\$(parse_git_branch) \n\[$GREEN\]\A \$ \[$RESET\]" diff --git a/tests_deployment/test_jupyterhub_ssh.py b/tests_deployment/test_jupyterhub_ssh.py index db3919376..7bd9a19e4 100644 --- a/tests_deployment/test_jupyterhub_ssh.py +++ b/tests_deployment/test_jupyterhub_ssh.py @@ -13,6 +13,8 @@ monkeypatch_ssl_context() +TIMEOUT_SECS = 300 + @pytest.fixture def paramiko_object(): @@ -57,12 +59,12 @@ def run_command(command, stdin, stdout, stderr): return "".join(output).strip() -@pytest.mark.timeout(120) +@pytest.mark.timeout(TIMEOUT_SECS) def test_simple_jupyterhub_ssh(paramiko_object): stdin, stdout, stderr = paramiko_object.exec_command("") -@pytest.mark.timeout(120) +@pytest.mark.timeout(TIMEOUT_SECS) def test_print_jupyterhub_ssh(paramiko_object): stdin, stdout, stderr = paramiko_object.exec_command("") @@ -81,7 +83,7 @@ def test_print_jupyterhub_ssh(paramiko_object): print(run_command(command, stdin, stdout, stderr)) -@pytest.mark.timeout(120) +@pytest.mark.timeout(TIMEOUT_SECS) def test_exact_jupyterhub_ssh(paramiko_object): stdin, stdout, stderr = paramiko_object.exec_command("") @@ -100,7 +102,7 @@ def test_exact_jupyterhub_ssh(paramiko_object): assert output == run_command(command, stdin, stdout, stderr) -@pytest.mark.timeout(120) +@pytest.mark.timeout(TIMEOUT_SECS) def test_contains_jupyterhub_ssh(paramiko_object): stdin, stdout, stderr = paramiko_object.exec_command("")