From a8e215506aa9bd472c1fd69d02126c64af88ae89 Mon Sep 17 00:00:00 2001 From: Von Random Date: Mon, 11 Nov 2024 12:07:22 +0200 Subject: [PATCH] fish: kube support --- cli/.config/fish/conf.d/prompt.fish | 4 +++- cli/.config/fish/functions/fish_prompt.fish | 1 + cli/.config/fish/functions/fish_prompt.git.fish | 2 +- cli/.config/fish/functions/fish_prompt.kube.fish | 8 ++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 cli/.config/fish/functions/fish_prompt.kube.fish diff --git a/cli/.config/fish/conf.d/prompt.fish b/cli/.config/fish/conf.d/prompt.fish index a9c7d0c..50a5b5d 100644 --- a/cli/.config/fish/conf.d/prompt.fish +++ b/cli/.config/fish/conf.d/prompt.fish @@ -1,5 +1,7 @@ set bang_symbol \u276f -set git_sign \ue0a0 +set kube_symbol \u2388 +set kube_config "$HOME/.kube/config" +set git_symbol \ue0a0 set color_git_branch brblack # git symbols and colors diff --git a/cli/.config/fish/functions/fish_prompt.fish b/cli/.config/fish/functions/fish_prompt.fish index 29d81cd..f375667 100644 --- a/cli/.config/fish/functions/fish_prompt.fish +++ b/cli/.config/fish/functions/fish_prompt.fish @@ -4,6 +4,7 @@ function fish_prompt fish_prompt.add \[ brblack fish_prompt.user fish_prompt.add (prompt_pwd) blue + fish_prompt.kube fish_prompt.git fish_prompt.add \] brblack fish_prompt.bang diff --git a/cli/.config/fish/functions/fish_prompt.git.fish b/cli/.config/fish/functions/fish_prompt.git.fish index 01e96f4..257c79b 100644 --- a/cli/.config/fish/functions/fish_prompt.git.fish +++ b/cli/.config/fish/functions/fish_prompt.git.fish @@ -6,7 +6,7 @@ function fish_prompt.git set git_branch (string match -r '[^# .]+' "$line") string match -qr '\[behind' $line && set git_branch "$git_branch?" string match -qr '\[ahead' $line && set git_branch "$git_branch!" - fish_prompt.add "$git_sign $git_branch" + fish_prompt.add "$git_symbol $git_branch" else string match -qr "^.[MD]" "$line" && set git_count[1] (math $git_count[1] + 1) string match -qr "^[MDARC]." "$line" && set git_count[2] (math $git_count[2] + 1) diff --git a/cli/.config/fish/functions/fish_prompt.kube.fish b/cli/.config/fish/functions/fish_prompt.kube.fish new file mode 100644 index 0000000..7b0d152 --- /dev/null +++ b/cli/.config/fish/functions/fish_prompt.kube.fish @@ -0,0 +1,8 @@ +function fish_prompt.kube + if ! test -r "$kube_config" + return + end + fish_prompt.add "$kube_symbol" + set -l kube_context (awk -F- '($1 == "current") {print $3}' "$kube_config") + fish_prompt.add "$kube_context" green +end