From 7d818f4c48e9f87877dc5d661098701f32673e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Mon, 22 Apr 2024 09:51:53 +0200 Subject: [PATCH] Add podman segment displaying remote connection Optionally expose the CONTAINER_CONNECTION variable in a segment. --- README.md | 4 ++++ functions/__bobthefish_colors.fish | 14 ++++++++++++++ functions/__bobthefish_glyphs.fish | 3 +++ functions/bobthefish_display_colors.fish | 4 ++++ functions/fish_prompt.fish | 11 +++++++++++ 5 files changed, 36 insertions(+) diff --git a/README.md b/README.md index 9dbc3c1..8a38c63 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,10 @@ This feature is disabled by default. Use `yes` to show the current Kubernetes co This feature is disabled by default. Use `yes` to show the current Kubernetes namespace. +#### `set -g theme_display_podman yes` + +This feature is disabled by default. Use `yes` to show the current podman remote connection name. + #### `set -g theme_display_aws_vault_profile yes` This feature is disabled by default. Use `yes` to show the currently executing [AWS Vault](https://github.com/99designs/aws-vault) profile. diff --git a/functions/__bobthefish_colors.fish b/functions/__bobthefish_colors.fish index 34a5d16..dcef892 100644 --- a/functions/__bobthefish_colors.fish +++ b/functions/__bobthefish_colors.fish @@ -28,6 +28,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant brcyan $colorfg set -x color_k8s magenta white --bold + set -x color_podman magenta white --bold set -x color_aws_vault blue $colorfg --bold set -x color_aws_vault_expired blue red --bold set -x color_username white black --bold @@ -64,6 +65,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant brcyan $colorfg set -x color_k8s magenta white --bold + set -x color_podman magenta white --bold set -x color_aws_vault blue $colorfg --bold set -x color_aws_vault_expired blue red --bold set -x color_username black white --bold @@ -100,6 +102,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant brcyan $colorfg set -x color_k8s magenta white --bold + set -x color_podman magenta white --bold set -x color_aws_vault blue $colorfg --bold set -x color_aws_vault_expired blue red --bold set -x color_username brgrey white --bold @@ -136,6 +139,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant brcyan $colorfg set -x color_k8s magenta white --bold + set -x color_podman magenta white --bold set -x color_aws_vault blue $colorfg --bold set -x color_aws_vault_expired blue red --bold set -x color_username grey black --bold @@ -178,6 +182,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $blue $green --bold set -x color_k8s $green $white --bold + set -x color_podman $blue $white --bold set -x color_aws_vault $blue $grey --bold set -x color_aws_vault_expired $blue $red --bold set -x color_username $grey $blue --bold @@ -231,6 +236,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $base0C $colorfg --bold set -x color_k8s $base06 $colorfg --bold + set -x color_podman $base0E $colorfg --bold set -x color_aws_vault $base0D $colorfg --bold set -x color_aws_vault_expired $base0D $base08 --bold set -x color_username $base02 $base0D --bold @@ -284,6 +290,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $base0C $colorfg --bold set -x color_k8s $base0B $colorfg --bold + set -x color_podman $base0E $colorfg --bold set -x color_aws_vault $base0D $base0A --bold set -x color_aws_vault_expired $base0D $base08 --bold set -x color_username $base02 $base0D --bold @@ -337,6 +344,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $violet $colorfg --bold set -x color_k8s $green $colorfg --bold + set -x color_podman $violet $colorfg --bold set -x color_aws_vault $violet $base3 --bold set -x color_aws_vault_expired $violet $orange --bold set -x color_username $base2 $blue --bold @@ -390,6 +398,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $violet $colorfg --bold set -x color_k8s $green $colorfg --bold + set -x color_podman $violet $colorfg --bold set -x color_aws_vault $violet $base3 --bold set -x color_aws_vault_expired $violet $orange --bold set -x color_username $base02 $blue --bold @@ -436,6 +445,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $blue[1] $white --bold set -x color_k8s $green[1] $colorfg --bold + set -x color_podman $blue[1] $white --bold set -x color_aws_vault $blue[3] $orange[1] --bold set -x color_aws_vault_expired $blue[3] $red[3] --bold set -x color_username $grey[1] $blue[3] --bold @@ -481,6 +491,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $blue[2] $fg[2] --bold set -x color_k8s $green[2] $fg[2] --bold + set -x color_podman $blue[2] $fg[2] --bold set -x color_aws_vault $blue[2] $yellow[1] --bold set -x color_aws_vault_expired $blue[2] $red[1] --bold set -x color_username $fg[3] $blue[2] --bold @@ -571,6 +582,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $pink $bg --bold set -x color_k8s $purple $bg --bold + set -x color_podman $purple $bg --bold set -x color_aws_vault $comment $yellow --bold set -x color_aws_vault_expired $comment $red --bold set -x color_username $selection $cyan --bold @@ -624,6 +636,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $base02 $colorfg --bold set -x color_k8s $base02 $colorfg --bold + set -x color_podman $base0E $colorfg --bold set -x color_aws_vault $base0A $base0D --bold set -x color_aws_vault_expired $base0A $base0B --bold set -x color_username $base02 $base0D --bold @@ -1018,6 +1031,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $blue[1] $white --bold set -x color_k8s $green[2] $white --bold + set -x color_podman $blue[1] $white --bold set -x color_aws_vault $blue[3] $orange[1] --bold set -x color_aws_vault_expired $blue[3] $red[3] --bold set -x color_username $grey[1] $blue[3] --bold diff --git a/functions/__bobthefish_glyphs.fish b/functions/__bobthefish_glyphs.fish index 1adb236..d06fe95 100644 --- a/functions/__bobthefish_glyphs.fish +++ b/functions/__bobthefish_glyphs.fish @@ -30,6 +30,9 @@ function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish' # Kubernetes glyphs set -x k8s_glyph \u2388 # '⎈' + # Podman glyphs + set -x podman_glyph \uf4b7 + # Vagrant glyphs set -x vagrant_running_glyph \u2191 # ↑ 'running' set -x vagrant_poweroff_glyph \u2193 # ↓ 'poweroff' diff --git a/functions/bobthefish_display_colors.fish b/functions/bobthefish_display_colors.fish index 39c025f..39bceb1 100644 --- a/functions/bobthefish_display_colors.fish +++ b/functions/bobthefish_display_colors.fish @@ -166,5 +166,9 @@ function bobthefish_display_colors -a color_scheme -d 'Print example prompt colo echo -ns $k8s_glyph ' k8s-context' __bobthefish_finish_segments + __bobthefish_start_segment $color_podman + echo -ns $podman_glyph ' podman' + __bobthefish_finish_segments + echo -e "\n" end diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 8789033..c208cc2 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -646,6 +646,16 @@ function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context' echo -ns $segment ' ' end +function __bobthefish_prompt_podman -S -d 'Show current podman connection' + [ "$theme_display_podman" = 'yes' ] + or return + + [ -z "$CONTAINER_CONNECTION" ] + and return + + __bobthefish_start_segment $color_podman + echo -ns $podman_glyph ' ' $CONTAINER_CONNECTION ' ' +end # ============================== # Cloud Tools @@ -1294,6 +1304,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' __bobthefish_prompt_vagrant __bobthefish_prompt_docker __bobthefish_prompt_k8s_context + __bobthefish_prompt_podman # Cloud Tools __bobthefish_prompt_aws_vault_profile