From d6f5dc9c34a7784b7f550bc010990fe3038c3488 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Tue, 17 Sep 2019 17:37:18 -0400 Subject: [PATCH] Update super prompt to use docker context. --- bash/super_prompt.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bash/super_prompt.sh b/bash/super_prompt.sh index 77304b7..b5837b0 100644 --- a/bash/super_prompt.sh +++ b/bash/super_prompt.sh @@ -30,4 +30,9 @@ function sp_path { echo $path } -export PS1="[${C_YELLOW}\u${C_NO}@${C_BLUE}${HOSTNAME}${C_NO}:${C_GREEN}\$(sp_path)${C_NO}] ${C_MAGENTA}\$(sp_git)${C_NO}\n${C_RED}\$ ${C_NO}" +function sp_docker_context { + local name=$(docker context inspect | grep Name | tr -d ' ' | sed -E "s/\"Name\":\"(.*)\",/\1/") + [ $name != 'default' ] && echo $name +} + +export PS1="[${C_YELLOW}\u${C_NO}@${C_BLUE}${HOSTNAME}${C_NO}:${C_GREEN}\$(sp_path)${C_NO}] ${C_MAGENTA}\$(sp_git)${C_NO} ${C_GREEN}\$(sp_docker_context)${C_NO} ${C_RED}\$(echo -n \$DOCKER_MACHINE_NAME)${C_NO} \n${C_RED}\$ ${C_NO}"