Skip to content

DrPhil/fish-kube-prompt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

fish-kube-prompt

⎈ kubectl context/namespace in your fish shell prompt

preview

Install

fisher add DrPhil/fish-kube-prompt

Then create or edit ~/.config/fish/functions/fish_prompt.fish to include __kube_prompt:

function fish_prompt
  echo -s (set_color blue) (__kube_prompt) (set_color $fish_color_cwd) " " (prompt_pwd) (set_color normal) "> "
end

Speed

Running the kubectl commands to get the context and namespace every time the prompt is shown would slow down the prompt significantly. Therefore, fish-kube-prompt caches the context and namespace by only calling kubectl when the env var KUBECONFIG has changed since the last cache update, or when the 'last modified' timestamp of the files in KUBECONFIG is newer than the timestamp of the last cache update.

This was not my idea, I took it from jonmosco/kube-ps1.

Config

You can toggle the prompt on or off like this:

kube_ps on
kube_ps off

kube_ps is a simple function that just updates a universal variable __kube_ps_enabled.

Many choices have been hard-coded (e.g. colors, delimiters). If there's anything you'd like to customize, please add an env var and send a PR.

Credits

Forked from https://github.com/aluxian/fish-kube-prompt

Inspired from the awesome work of:

Author

Alexandru Rosianu (https://github.com/aluxian/dotfiles-fish)

License

MIT

About

⎈ kubectl context/namespace in your fish shell prompt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%