From eca5904f1a7b48c9951dda7336aacb359a530b27 Mon Sep 17 00:00:00 2001 From: Bartek Stalewski Date: Wed, 15 Jan 2020 13:13:57 +0100 Subject: [PATCH] Namespace, fixes. --- zsh/{k8s.zsh => slimline_k8s_ctx.zsh} | 5 ++--- zsh/slimline_k8s_ns.zsh | 18 ++++++++++++++++++ zsh/zshrc | 12 +++++++----- 3 files changed, 27 insertions(+), 8 deletions(-) rename zsh/{k8s.zsh => slimline_k8s_ctx.zsh} (66%) create mode 100644 zsh/slimline_k8s_ns.zsh diff --git a/zsh/k8s.zsh b/zsh/slimline_k8s_ctx.zsh similarity index 66% rename from zsh/k8s.zsh rename to zsh/slimline_k8s_ctx.zsh index 1d4feae..22aacdd 100644 --- a/zsh/k8s.zsh +++ b/zsh/slimline_k8s_ctx.zsh @@ -4,7 +4,6 @@ slimline::section::k8s_context::precmd() { slimline::section::k8s_context::async_task() { kubectl config current-context - # gsed -nr '/current-context/s/(.*) (.*)/\2/p' ~/.kube/config } slimline::section::k8s_context::async_task_complete() { @@ -14,6 +13,6 @@ slimline::section::k8s_context::async_task_complete() { slimline::section::k8s_context::render() { [[ -z "${slimline_section_k8s_context_output}" ]] && return - slimline::utils::expand "k8s_context" "[k8s:%F{blue}|output|%f]" \ - "output" "${slimline_section_k8s_context_output}" \ + slimline::utils::expand "k8s_context" "ctx:%F{blue}|output|%f" \ + "output" "${slimline_section_k8s_context_output}" } diff --git a/zsh/slimline_k8s_ns.zsh b/zsh/slimline_k8s_ns.zsh new file mode 100644 index 0000000..a1c1fb9 --- /dev/null +++ b/zsh/slimline_k8s_ns.zsh @@ -0,0 +1,18 @@ +slimline::section::k8s_namespace::precmd() { + unset slimline_section_k8s_namespace_output +} + +slimline::section::k8s_namespace::async_task() { + kubectl config view --minify --output 'jsonpath={..namespace}' +} + +slimline::section::k8s_namespace::async_task_complete() { + slimline_section_k8s_namespace_output=$2 +} + +slimline::section::k8s_namespace::render() { + [[ -z "${slimline_section_k8s_namespace_output}" ]] && return + + slimline::utils::expand "k8s_namespace" "ns:%F{blue}|output|%f" \ + "output" "${slimline_section_k8s_namespace_output}" +} diff --git a/zsh/zshrc b/zsh/zshrc index 8b44ec9..1d2057c 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -13,14 +13,16 @@ alias ll='ls -lh' source ~/.zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh source ~/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh -source ~/.dotfiles/zsh/k8s.zsh +source ~/.dotfiles/zsh/slimline_k8s_ctx.zsh +source ~/.dotfiles/zsh/slimline_k8s_ns.zsh -SLIMLINE_RIGHT_PROMPT_SECTIONS="execution_time git virtualenv aws_profile k8s_context" +SLIMLINE_LEFT_PROMPT_SECTIONS="user_host_info cwd git symbol" +SLIMLINE_RIGHT_PROMPT_SECTIONS="exit_status execution_time virtualenv aws_profile k8s_context k8s_namespace" SLIMLINE_USER_HOST_INFO_FORMAT="%F{green}|user|%F{white}@%F{cyan}|host|%f" SLIMLINE_USER_HOST_INFO_ROOT_FORMAT="%F{red}|user|%F{white}@%F{cyan}|host|%f" -SLIMLINE_VIRTUALENV_FORMAT="[venv:%F{blue}|basename|%f]" -SLIMLINE_AWS_PROFILE_FORMAT="[aws:%F{blue}|profile|%f]" -SLIMLINE_SYMBOL_WORKING_FORMAT="%F{red}➜%f" +SLIMLINE_VIRTUALENV_FORMAT="venv:%F{blue}|basename|%f" +SLIMLINE_AWS_PROFILE_FORMAT="aws:%F{blue}|profile|%f" +SLIMLINE_SYMBOL_WORKING_FORMAT="%F{243}➜%f" SLIMLINE_SYMBOL_READY_FORMAT="%F{243}➜%f" SLIMLINE_MAX_EXEC_TIME=2 source ~/.zsh/themes/slimline/slimline.zsh