From 26f1a8d5720755e4f4bfb29a004dbb65074f25de Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Sat, 23 Apr 2022 18:47:05 -0400 Subject: [PATCH] Support multiple 'default' contexts for Docker (#283) * Support multiple 'default' contexts for Docker If someone is using 'colima' instead of Docker Desktop, the default context is 'colima'. Rather than making two tests with fixed values, add a new configuration variable and use `contains`. * Remove non-colour configuration from color files --- functions/_tide_item_docker.fish | 3 ++- functions/tide/configure/configs/classic.fish | 1 + functions/tide/configure/configs/lean.fish | 1 + functions/tide/configure/configs/rainbow.fish | 1 + tests/_tide_item_docker.test.fish | 7 +++++++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/functions/_tide_item_docker.fish b/functions/_tide_item_docker.fish index 6bcc23f..4eec0bf 100644 --- a/functions/_tide_item_docker.fish +++ b/functions/_tide_item_docker.fish @@ -1,4 +1,5 @@ function _tide_item_docker docker context inspect --format '{{.Name}}' | read -l context - test "$context" != default && _tide_print_item docker $tide_docker_icon' ' $context + contains -- "$context" $tide_docker_default_contexts || + _tide_print_item docker $tide_docker_icon' ' $context end diff --git a/functions/tide/configure/configs/classic.fish b/functions/tide/configure/configs/classic.fish index 55cba37..795f414 100644 --- a/functions/tide/configure/configs/classic.fish +++ b/functions/tide/configure/configs/classic.fish @@ -20,6 +20,7 @@ tide_context_color_ssh D7AF87 tide_docker_bg_color 444444 tide_docker_color 2496ED tide_docker_icon  +tide_docker_default_contexts default colima tide_git_bg_color 444444 tide_git_bg_color_unstable 444444 tide_git_bg_color_urgent 444444 diff --git a/functions/tide/configure/configs/lean.fish b/functions/tide/configure/configs/lean.fish index 95f680b..7b2047d 100644 --- a/functions/tide/configure/configs/lean.fish +++ b/functions/tide/configure/configs/lean.fish @@ -19,6 +19,7 @@ tide_context_color_root $_tide_color_gold tide_context_color_ssh D7AF87 tide_docker_bg_color normal tide_docker_color 2496ED +tide_docker_default_contexts default colima tide_docker_icon  tide_git_bg_color normal tide_git_bg_color_unstable normal diff --git a/functions/tide/configure/configs/rainbow.fish b/functions/tide/configure/configs/rainbow.fish index 889dae5..2c9025f 100644 --- a/functions/tide/configure/configs/rainbow.fish +++ b/functions/tide/configure/configs/rainbow.fish @@ -19,6 +19,7 @@ tide_context_color_root $_tide_color_gold tide_context_color_ssh D7AF87 tide_docker_bg_color 2496ED tide_docker_color 000000 +tide_docker_default_contexts default colima tide_docker_icon  tide_git_bg_color 4E9A06 tide_git_bg_color_unstable C4A000 diff --git a/tests/_tide_item_docker.test.fish b/tests/_tide_item_docker.test.fish index a268f1c..39b8377 100644 --- a/tests/_tide_item_docker.test.fish +++ b/tests/_tide_item_docker.test.fish @@ -9,5 +9,12 @@ set -lx tide_docker_icon  mock docker "context inspect" "printf default" _docker # CHECK: +mock docker "context inspect" "printf colima" +_docker # CHECK: + mock docker "context inspect" "printf curr-context" _docker # CHECK:  curr-context + +mock docker "context inspect" "printf curr-context" +set -lx tide_docker_default_contexts curr-context +_docker # CHECK: