From 6583634a9f60360be32d9167bae81a6e5674ea07 Mon Sep 17 00:00:00 2001 From: Avital Tamir Date: Tue, 8 Aug 2017 10:46:20 +0300 Subject: [PATCH] Added support for showing current kubernetes context --- fish_prompt.fish | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fish_prompt.fish b/fish_prompt.fish index 8d47335..43711c5 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -23,6 +23,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_k8s_context no # set -g theme_display_hg yes # set -g theme_display_virtualenv no # set -g theme_display_ruby no @@ -491,6 +492,12 @@ function __bobthefish_prompt_docker -S -d 'Display Docker machine name' echo -ns $DOCKER_MACHINE_NAME ' ' end +function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context' + [ "$theme_display_k8s_context" = 'no' -o ! -f ~/.kube/config ]; and return + __bobthefish_start_segment $__color_k8s + echo -ns (grep current-context ~/.kube/config | awk '{print $2}') ' ' +end + # ============================== # User / hostname info segments @@ -1063,6 +1070,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual bryellow $colorfg --bold set __color_vagrant brcyan $colorfg + set __color_k8s magenta white --bold set __color_username white black --bold set __color_hostname white black set __color_rvm brmagenta $colorfg --bold @@ -1091,6 +1099,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual bryellow $colorfg --bold set __color_vagrant brcyan $colorfg + set __color_k8s magenta white --bold set __color_username black white --bold set __color_hostname black white set __color_rvm brmagenta $colorfg --bold @@ -1119,6 +1128,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual bryellow $colorfg --bold set __color_vagrant brcyan $colorfg + set __color_k8s magenta white --bold set __color_username brgrey white --bold set __color_hostname brgrey white set __color_rvm brmagenta $colorfg --bold @@ -1147,6 +1157,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual bryellow $colorfg --bold set __color_vagrant brcyan $colorfg + set __color_k8s magenta white --bold set __color_username grey black --bold set __color_hostname grey black set __color_rvm brmagenta $colorfg --bold @@ -1181,6 +1192,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual $yellow $grey --bold set __color_vagrant $blue $green --bold + set __color_k8s $green $white --bold set __color_username $grey $blue --bold set __color_hostname $grey $blue set __color_rvm $red $grey --bold @@ -1226,6 +1238,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual $base09 $colorfg --bold set __color_vagrant $base0C $colorfg --bold + set __color_k8s $base06 $colorfg --bold set __color_username $base02 $base0D --bold set __color_hostname $base02 $base0D set __color_rvm $base08 $colorfg --bold @@ -1271,6 +1284,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual $base09 $colorfg --bold set __color_vagrant $base0C $colorfg --bold + set __color_k8s $base0B $colorfg --bold set __color_username $base02 $base0D --bold set __color_hostname $base02 $base0D set __color_rvm $base08 $colorfg --bold @@ -1316,6 +1330,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual $yellow $colorfg --bold set __color_vagrant $violet $colorfg --bold + set __color_k8s $green $colorfg --bold set __color_username $base2 $blue --bold set __color_hostname $base2 $blue set __color_rvm $red $colorfg --bold @@ -1361,6 +1376,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual $yellow $colorfg --bold set __color_vagrant $violet $colorfg --bold + set __color_k8s $green $colorfg --bold set __color_username $base02 $blue --bold set __color_hostname $base02 $blue set __color_rvm $red $colorfg --bold @@ -1399,6 +1415,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual $orange[1] $orange[3] --bold set __color_vagrant $blue[1] $white --bold + set __color_k8s $green[1] $colorfg --bold set __color_username $grey[1] $blue[3] --bold set __color_hostname $grey[1] $blue[3] set __color_rvm $ruby_red $grey[1] --bold @@ -1436,6 +1453,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual $yellow[1] $bg[2] --bold set __color_vagrant $blue[2] $fg[2] --bold + set __color_k8s $green[2] $fg[2] --bold set __color_username $fg[3] $blue[2] --bold set __color_hostname $fg[3] $blue[2] set __color_rvm $red[2] $fg[2] --bold @@ -1474,6 +1492,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set __color_vi_mode_visual $orange[1] $orange[3] --bold set __color_vagrant $blue[1] $white --bold + set __color_k8s $green[2] $white --bold set __color_username $grey[1] $blue[3] --bold set __color_hostname $grey[1] $blue[3] set __color_rvm $ruby_red $grey[1] --bold @@ -1494,6 +1513,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' # Containers and VMs __bobthefish_prompt_vagrant __bobthefish_prompt_docker + __bobthefish_prompt_k8s_context # User / hostname info __bobthefish_prompt_user