1
0
Fork 0

fish: kube support

This commit is contained in:
Von Random 2024-11-11 12:07:22 +02:00
parent afce6858f2
commit a8e215506a
4 changed files with 13 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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