feat(prompt): mostra namespace k8s, stato job running/stopped e nuovi glyph
This commit is contained in:
@@ -120,16 +120,21 @@ function fish_prompt --description 'Write out the prompt'
|
||||
echo -n (prompt_pwd)
|
||||
set_color normal
|
||||
|
||||
# Git + Kubernetes cluster
|
||||
# Git
|
||||
set -l vcs (fish_vcs_prompt)
|
||||
if test -n "$vcs"
|
||||
printf '%s' $vcs
|
||||
# Kubernetes context
|
||||
# Kubernetes context + namespace
|
||||
if command -sq kubectl
|
||||
set -l kctx (kubectl config current-context 2>/dev/null)
|
||||
set -l kns (kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)
|
||||
if test -n "$kctx"
|
||||
set_color brblack
|
||||
echo -n " [$kctx]"
|
||||
echo -n " ☸$kctx"
|
||||
if test -n "$kns" -a "$kns" != default
|
||||
set_color bryellow
|
||||
echo -n ":$kns"
|
||||
end
|
||||
set_color normal
|
||||
end
|
||||
end
|
||||
@@ -142,14 +147,28 @@ function fish_prompt --description 'Write out the prompt'
|
||||
echo -n $prompt_status
|
||||
set_color normal
|
||||
|
||||
# Background jobs counter
|
||||
set -l jobs_count (count (jobs -p))
|
||||
if test $jobs_count -gt 0
|
||||
# Background jobs: [N|M] running in green, stopped in yellow
|
||||
set -l n_running (count (jobs | string match -r '\trunning\t'))
|
||||
set -l n_stopped (count (jobs | string match -r '\tstopped\t'))
|
||||
if test $n_running -gt 0 -o $n_stopped -gt 0
|
||||
set_color yellow
|
||||
echo -n "[$jobs_count] "
|
||||
echo -n '['
|
||||
set_color normal
|
||||
set_color green
|
||||
echo -n $n_running
|
||||
set_color normal
|
||||
set_color yellow
|
||||
echo -n '|'
|
||||
set_color normal
|
||||
set_color yellow
|
||||
echo -n $n_stopped
|
||||
set_color normal
|
||||
set_color yellow
|
||||
echo -n '] '
|
||||
set_color normal
|
||||
end
|
||||
|
||||
# Prompt on new line
|
||||
echo
|
||||
echo '>-< <~> >>=>>=>> '
|
||||
echo '<-> '
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user