Feature: Truncate kubectl context using variables

Requires the following variables to be defined.

Example variable definition:
set -x tide_kubectl_truncation_strategy l
set -x tide_kubectl_truncation_length 31

Same approach as in:
447945d2cf/functions/_tide_item_git.fish (L2)
This commit is contained in:
Rodrigo 2023-04-17 17:46:42 +02:00 committed by GitHub
parent 447945d2cf
commit c218a4a945
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
function _tide_item_kubectl function _tide_item_kubectl
kubectl config view --minify --output 'jsonpath={.current-context}/{..namespace}' 2>/dev/null | read -l context && kubectl config view --minify --output 'jsonpath={.current-context}/{..namespace}' 2>/dev/null | string shorten -"$tide_kubectl_truncation_strategy"m"$tide_kubectl_truncation_length" | read -l context &&
_tide_print_item kubectl $tide_kubectl_icon' ' (string replace -r '/(|default)$' '' $context) _tide_print_item kubectl $tide_kubectl_icon' ' (string replace -r '/(|default)$' '' $context)
end end