adding kubernetes info to prompt

This commit is contained in:
2019-09-09 18:50:22 +02:00
parent c55d783731
commit 359651001b
5 changed files with 21 additions and 11 deletions

View File

@@ -66,4 +66,4 @@ set fish_greeting ''
set -g fish_user_paths "/usr/local/sbin" $fish_user_paths
# add kitty support
kitty + complete setup fish | source
# kitty + complete setup fish | source

View File

@@ -1,4 +1,3 @@
function az_web --description 'Use az web'
az aks browse --name aks-$argv --resource-group $argv
end

View File

@@ -10,6 +10,10 @@ function _rb_prompt
echo (rbenv version | awk '{print $1}')
end
function _kb_context
echo (kubectl config current-context | awk '{print $1}')
end
function fish_prompt
set -l cyan (set_color -o cyan)
set -l magenta (set_color -o magenta)
@@ -22,18 +26,22 @@ function fish_prompt
# set -l arrow "$red↪ $normal"
set -l cwd $cyan(pwd|sed "s=$HOME=~=")
set -l ruby_version $magenta(_rb_prompt)
set -l ruby_version "$ruby_version$normal in "
if [ (_kb_context) ]
set -l kb_context $yellow(_kb_context)
set kube_context "|$kb_context"
end
set -l ruby_version $magenta(_rb_prompt)
set -l ruby_version "[$ruby_version$normal$kube_context$normal] in "
if [ (_git_branch_name) ]
set -l git_branch $red(_git_branch_name)
set git_info "$normal on $blue$git_branch$blue"
set -l git_branch $red(_git_branch_name)
set git_info "$normal on $blue$git_branch$blue"
if [ (_is_git_dirty) ]
set -l dirty "$yellow"
set git_info "$git_info$dirty"
end
if [ (_is_git_dirty) ]
set -l dirty "$yellow"
set git_info "$git_info$dirty"
end
end
echo -s $ruby_version $cwd $git_info $normal \n $arrow " "

3
fish/functions/kc.fish Normal file
View File

@@ -0,0 +1,3 @@
function kc --description 'switch context to dev, int or prod'
kubectl config use-context aks-$argv
end

View File

@@ -172,7 +172,7 @@ font_size 15.0
#: special value default means to use the operating system's default
#: URL handler.
# copy_on_select no
copy_on_select yes
#: Copy to clipboard or a private buffer on select. With this set to
#: clipboard, simply selecting text with the mouse will cause the text