From 0bf70d670a1d91176db9fe365d5a04197a754b96 Mon Sep 17 00:00:00 2001 From: Michael Favia Date: Tue, 9 Jan 2018 12:05:11 -0600 Subject: [PATCH] Add an error message if the binary isn't found and a few more commonly used commands. --- plugins/kubectl/kubectl.plugin.zsh | 102 +++++++++++++++++------------ 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 88177b5a0..4545f60c6 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -3,48 +3,66 @@ # Author: https://github.com/pstadler if [ $commands[kubectl] ]; then + + # Let kubectl load up the autocompletions source <(kubectl completion zsh) + + # This command is used ALOT both below and in daily life + alias k=kubectl + + # Drop into an interactive terminal on a container + alias keti='k exec -ti' + + # Manage configuration quickly to switch contexts between local, dev ad staging. + alias kcgc='k config get-contexts' + alias kcuc='k config use-context' + alias kcsc='k config set-context' + alias kcdc='k config delete-context' + alias kccc='k config current-context' + + # Pod management. + alias kgp='k get pods' + alias kgpa='k get pods --all-namespaces' + alias klp='k logs pods' + alias kep='k edit pods' + alias kdp='k describe pods' + alias kdelp='k delete pods' + + # Service management. + alias kgs='k get svc' + alias kgsa='k get svc --all-namespaces' + alias kes='k edit svc' + alias kds='k describe svc' + alias kdels='k delete svc' + + # Secret management + alias kgsec='k get secret' + alias kdsec='k describe secret' + alias kdelsec='k delete secret' + + # Deployment management. + alias kgd='k get deployment' + alias ked='k edit deployment' + alias kdd='k describe deployment' + alias kdeld='k delete deployment' + alias ksd='k scale deployment' + alias krsd='k rollout status deployment' + + # Rollout management. + alias kgrs='k get rs' + alias krh='k rollout history' + alias kru='k rollout undo' + + # Node management + alias kgn='k get nodes' + alias kdn='k describe nodes' + + # Port Forwarding + alias kpf='k port-forward' + +else + RED='\033[0;31m' + NC='\033[0m' # No Color + printf "${RED}kubectl plugin loaded in .oh-my-zsh but cannot find kubectl binary in current PATH:\n $PATH${NC}" 1>&2 fi -# This command is used ALOT both below and in daily life -alias k=kubectl - -# Drop into an interactive terminal on a container -alias keti='k exec -ti' - -# Manage configuration quickly to switch contexts between local, dev ad staging. -alias kcuc='k config use-context' -alias kcsc='k config set-context' -alias kcdc='k config delete-context' -alias kccc='k config current-context' - -# Pod management. -alias kgp='k get pods' -alias klp='k logs pods' -alias kep='k edit pods' -alias kdp='k describe pods' -alias kdelp='k delete pods' - -# Service management. -alias kgs='k get svc' -alias kes='k edit svc' -alias kds='k describe svc' -alias kdels='k delete svc' - -# Secret management -alias kgsec='k get secret' -alias kdsec='k describe secret' -alias kdelsec='k delete secret' - -# Deployment management. -alias kgd='k get deployment' -alias ked='k edit deployment' -alias kdd='k describe deployment' -alias kdeld='k delete deployment' -alias ksd='k scale deployment' -alias krsd='k rollout status deployment' - -# Rollout management. -alias kgrs='k get rs' -alias krh='k rollout history' -alias kru='k rollout undo'