All Projects β†’ superbrothers β†’ Zsh Kubectl Prompt

superbrothers / Zsh Kubectl Prompt

Licence: mit
Display information about the kubectl current context and namespace in zsh prompt.

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Zsh Kubectl Prompt

Gbt
Highly configurable prompt builder for Bash, ZSH and PowerShell written in Go.
Stars: ✭ 457 (+33.63%)
Mutual labels:  zsh, prompt, kubectl
Spaceship Prompt
πŸš€β­ A Zsh prompt for Astronauts
Stars: ✭ 15,748 (+4504.68%)
Mutual labels:  zsh, prompt
Common
A simple, clean and minimal prompt.
Stars: ✭ 213 (-37.72%)
Mutual labels:  zsh, prompt
auto-ls
zsh plugin for auto-ls
Stars: ✭ 77 (-77.49%)
Mutual labels:  zsh, prompt
Powerline
Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome and Qtile.
Stars: ✭ 12,989 (+3697.95%)
Mutual labels:  zsh, prompt
Agkozak Zsh Prompt
A fast, asynchronous ZSH prompt with color ASCII indicators of Git, exit, SSH, virtual environment, and vi mode status. Framework-agnostic and customizable.
Stars: ✭ 182 (-46.78%)
Mutual labels:  zsh, prompt
fish-kube-prompt
⎈ kubectl context/namespace in your fish shell prompt
Stars: ✭ 71 (-79.24%)
Mutual labels:  prompt, kubectl
Nicy
❄️ a nice and icy zsh and bash prompt in Nim
Stars: ✭ 148 (-56.73%)
Mutual labels:  zsh, prompt
zsh-prompt-generator
Zsh Prompt Generator
Stars: ✭ 39 (-88.6%)
Mutual labels:  zsh, prompt
enquirer
Stylish, intuitive and user-friendly prompts, for Node.js. Used by eslint, webpack, yarn, pm2, pnpm, RedwoodJS, FactorJS, salesforce, Cypress, Google Lighthouse, Generate, tencent cloudbase, lint-staged, gluegun, hygen, hardhat, AWS Amplify, GitHub Actions Toolkit, @airbnb/nimbus, and many others! Please follow Enquirer's author: https://github.…
Stars: ✭ 6,523 (+1807.31%)
Mutual labels:  zsh, prompt
bashy
Extremely fast and simple git prompt for bash and zsh
Stars: ✭ 43 (-87.43%)
Mutual labels:  zsh, prompt
Promptless
πŸš€ A super fast and extremely minimal shell prompt.
Stars: ✭ 155 (-54.68%)
Mutual labels:  zsh, prompt
Zsh Prompt Garrett
A prompt with the information you need the moment you need it.
Stars: ✭ 150 (-56.14%)
Mutual labels:  zsh, prompt
Kube Ps1
Kubernetes prompt info for bash and zsh
Stars: ✭ 2,499 (+630.7%)
Mutual labels:  zsh, kubectl
Shelby
Shelby is a fast ⚑️ , lightweight ☁️ , minimal✨, shell prompt written in Go.
Stars: ✭ 148 (-56.73%)
Mutual labels:  zsh, prompt
Silver
A cross-shell customizable powerline-like prompt with icons
Stars: ✭ 238 (-30.41%)
Mutual labels:  zsh, prompt
apollo-zsh-theme
Heavily customizable, compatible, and fast ZSH theme framework.
Stars: ✭ 64 (-81.29%)
Mutual labels:  zsh, prompt
Polyglot
Color, ASCII-only Git prompt for zsh, bash, ksh93, mksh, pdksh, dash, and busybox ash
Stars: ✭ 118 (-65.5%)
Mutual labels:  zsh, prompt
Lean
Pretty, minimal, one-line, fast ZSH prompt
Stars: ✭ 136 (-60.23%)
Mutual labels:  zsh, prompt
gitprompt
Display git status in the the terminal prompt
Stars: ✭ 22 (-93.57%)
Mutual labels:  zsh, prompt

zsh-kubectl-prompt

This script displays information about the kubectl current context and namespace in zsh prompt.

Screenshot

Usage

Clone this repository and source the kubectl.zsh from your ~/.zshrc config file, and configure your prompt.

autoload -U colors; colors
source /path/to/zsh-kubectl-prompt/kubectl.zsh
RPROMPT='%{$fg[blue]%}($ZSH_KUBECTL_PROMPT)%{$reset_color%}'

Or create different style depending on user, context, namespace. The plugin creates 4 variables:

  • ZSH_KUBECTL_CONTEXT
  • ZSH_KUBECTL_NAMESPACE
  • ZSH_KUBECTL_PROMPT
  • ZSH_KUBECTL_USER

For example, make the prompt red when the username matches admin.

autoload -U colors; colors
source /path/to/zsh-kubectl-prompt/kubectl.zsh
function right_prompt() {
  local color="blue"

  if [[ "$ZSH_KUBECTL_USER" =~ "admin" ]]; then
    color=red
  fi

  echo "%{$fg[$color]%}($ZSH_KUBECTL_PROMPT)%{$reset_color%}"
}
RPROMPT='$(right_prompt)'

Also you can install with homebrew.

$ brew tap superbrothers/zsh-kubectl-prompt
$ brew install zsh-kubectl-prompt

Customization

Change the separator between context and namespace:

zstyle ':zsh-kubectl-prompt:' separator '|'

Add custom character before the prompt:

zstyle ':zsh-kubectl-prompt:' preprompt '<'

Add custom character after the prompt:

zstyle ':zsh-kubectl-prompt:' postprompt '>'

Does not display the current namespace:

zstyle ':zsh-kubectl-prompt:' namespace false

Use another binary instead of kubectl to get the information (e.g. oc):

zstyle ':zsh-kubectl-prompt:' binary 'oc'

With a plugin manager

If you use zgen, load this repository as follows:

source "${HOME}/.zgen/zgen.zsh"

# if the init script doesn't exist
if ! zgen saved; then
    # specify plugins here
    zgen load superbrothers/zsh-kubectl-prompt

    # generate the init script from plugins above
    zgen save
fi

autoload -U colors; colors
RPROMPT='%{$fg[blue]%}($ZSH_KUBECTL_PROMPT)%{$reset_color%}'

If you use antigen, load this repository as follows:

source /path-to-antigen/antigen.zsh

# load this plugin
antigen bundle superbrothers/zsh-kubectl-prompt

# tell antigen that you're done.
antigen apply

autoload -U colors; colors
RPROMPT='%{$fg[blue]%}($ZSH_KUBECTL_PROMPT)%{$reset_color%}'

If you use oh-my-zsh, load this repository as follows:

  1. Clone the repo into oh-my-zsh custom plugins folder
git clone [email protected]:superbrothers/zsh-kubectl-prompt.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-kubectl-prompt
  1. Activate the plugin your .zshrc by appending it to the plugin section
plugins=( [plugins...] zsh-kubectl-prompt)

Note: Remember to source the .zshrc or restart your shell after step 2

License

This script is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].