├── fishfile ├── .github └── FUNDING.yml ├── functions ├── fish_prompt.fish └── fish_right_prompt.fish ├── README.md └── LICENSE /fishfile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [Ladicle] 4 | -------------------------------------------------------------------------------- /functions/fish_prompt.fish: -------------------------------------------------------------------------------- 1 | function fish_prompt 2 | set -l time (set_color yellow)(date "+(%H:%M:%S)") 3 | set -l dir (set_color white)"["(prompt_pwd)"]" 4 | set -l git (set_color green)(git rev-parse --abbrev-ref HEAD 2>/dev/null; or echo "") 5 | set -l cursor (set_color red)"❯"(set_color yellow)"❯"(set_color green)"❯ " 6 | 7 | echo $dir $time $git 8 | echo $cursor 9 | end 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fish-kubectl-prompt 2 | 3 | [![Slack Room][slack-badge]][slack-link] 4 | 5 | Display information about the kubectl current context and namespace in fish prompt. 6 | 7 | ![normal-prompt](https://user-images.githubusercontent.com/1159133/33415205-5f428d52-d5d8-11e7-9ecb-e78fa8c784e0.png) 8 | ![error-prompt](https://user-images.githubusercontent.com/1159133/33415236-908ee694-d5d8-11e7-9eb0-307cd512ae4b.png) 9 | 10 | ## CUSTOMIZE 11 | 12 | If you want to customize, override the following environment variables. 13 | 14 | set KUBECTL_PROMPT_ICON "⎈" 15 | set KUBECTL_PROMPT_SEPARATOR "/" 16 | 17 | ## Install 18 | 19 | With [fisherman] 20 | 21 | ``` 22 | fisher add Ladicle/fish-kubectl-prompt 23 | ``` 24 | 25 | [slack-link]: https://fisherman-wharf.herokuapp.com 26 | [slack-badge]: https://fisherman-wharf.herokuapp.com/badge.svg 27 | [fisherman]: https://github.com/fisherman/fisherman 28 | -------------------------------------------------------------------------------- /functions/fish_right_prompt.fish: -------------------------------------------------------------------------------- 1 | function kubectl_status 2 | [ -z "$KUBECTL_PROMPT_ICON" ]; and set -l KUBECTL_PROMPT_ICON "⎈" 3 | [ -z "$KUBECTL_PROMPT_SEPARATOR" ]; and set -l KUBECTL_PROMPT_SEPARATOR "/" 4 | set -l config $KUBECONFIG 5 | [ -z "$config" ]; and set -l config "$HOME/.kube/config" 6 | if [ ! -f $config ] 7 | echo (set_color red)$KUBECTL_PROMPT_ICON" "(set_color white)"no config" 8 | return 9 | end 10 | 11 | set -l ctx (kubectl config current-context 2>/dev/null) 12 | if [ $status -ne 0 ] 13 | echo (set_color red)$KUBECTL_PROMPT_ICON" "(set_color white)"no context" 14 | return 15 | end 16 | 17 | set -l ns (kubectl config view -o "jsonpath={.contexts[?(@.name==\"$ctx\")].context.namespace}") 18 | [ -z $ns ]; and set -l ns 'default' 19 | 20 | echo (set_color cyan)$KUBECTL_PROMPT_ICON" "(set_color white)"($ctx$KUBECTL_PROMPT_SEPARATOR$ns)" 21 | end 22 | 23 | function fish_right_prompt 24 | echo (kubectl_status) 25 | end 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 ladicle 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | --------------------------------------------------------------------------------