From 8dacb66d17d47a1e349523bdf50fa5b30c215154 Mon Sep 17 00:00:00 2001 From: Kamil Ostaszewski Date: Wed, 11 May 2022 19:27:51 +0200 Subject: [PATCH] Add support for docker context --- README.md | 1 + functions/fish_prompt.fish | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index ddd26f1..fdc89c1 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ set -g theme_git_worktree_support yes set -g theme_use_abbreviated_branch_name yes set -g theme_display_vagrant yes set -g theme_display_docker_machine no +set -g theme_display_docker_context no set -g theme_display_k8s_context yes set -g theme_display_hg yes set -g theme_display_virtualenv no diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 331bc5b..e5e728b 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -28,6 +28,7 @@ # set -g theme_git_worktree_support yes # set -g theme_display_vagrant yes # set -g theme_display_docker_machine no +# set -g theme_display_docker_context no # set -g theme_display_k8s_context yes # set -g theme_display_k8s_namespace no # set -g theme_display_aws_vault_profile yes @@ -599,6 +600,17 @@ function __bobthefish_prompt_docker -S -d 'Display Docker machine name' echo -ns $DOCKER_MACHINE_NAME ' ' end +function __bobthefish_prompt_docker_context -S -d 'Display Docker context' + [ "$theme_display_docker_context" = 'no' ] + and return + set -l docker_context (docker context inspect -f '{{.Name}}') + [ "$docker_context" = 'default' -o -z "docker_context" ] + and return + + __bobthefish_start_segment $color_vagrant + echo -ns $docker_context ' ' +end + function __bobthefish_k8s_context -S -d 'Get the current k8s context' set -l config_paths "$HOME/.kube/config" [ -n "$KUBECONFIG" ] @@ -1163,6 +1175,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' # Containers and VMs __bobthefish_prompt_vagrant __bobthefish_prompt_docker + __bobthefish_prompt_docker_context __bobthefish_prompt_k8s_context # Cloud Tools