Unverified Commit 0232ac4b authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

Merge branch 'master' into master

parents afb02876 ebc700be
......@@ -3,7 +3,7 @@
# Warning : Jakefile should have the right case : Jakefile or jakefile
# Tested on : MacOSX 10.7 (Lion), Ubuntu 11.10
# Author : Alexandre Lacheze (@al3xstrat)
# Inspiration : http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh
# Inspiration : https://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh
function _jake () {
if [ -f Jakefile ]||[ -f jakefile ]; then
......
# jenv plugin
[jenv](https://www.jenv.be/) is a Java version manager similiar to [rbenv](https://github.com/rbenv/rbenv)
and [pyenv](https://github.com/yyuu/pyenv).
This plugin initializes jenv and provides the `jenv_prompt_info` function to add Java
version information to prompts.
To use, add `jenv` to your plugins array in your zshrc file:
```zsh
plugins=(... jenv)
```
## Theme example
You can modify your `$PROMPT` or `$RPROMPT` variables to run `jenv_prompt_info`.
For example:
```
PROMPT="%~$ "
RPROMPT='$(jenv_prompt_info)'
```
changes your prompt to:
```
~/java/project$ ▋ oracle64-1.6.0.39
```
jenvdirs=("$HOME/.jenv" "/usr/local" "/usr/local/jenv" "/opt/jenv")
FOUND_JENV=0
for jenvdir in $jenvdirs; do
if [[ -d "${jenvdir}/bin" ]]; then
FOUND_JENV=1
break
fi
done
if [[ $FOUND_JENV -eq 0 ]]; then
if (( $+commands[brew] )) && jenvdir="$(brew --prefix jenv)"; then
[[ -d "${jenvdir}/bin" ]] && FOUND_JENV=1
fi
fi
if [[ $FOUND_JENV -eq 1 ]]; then
export PATH="${jenvdir}/bin:$PATH"
eval "$(jenv init - zsh)"
function jenv_prompt_info() { jenv version-name 2>/dev/null }
if [[ -d "${jenvdir}/versions" ]]; then
export JENV_ROOT=$jenvdir
fi
else
function jenv_prompt_info() { echo "system: $(java -version 2>&1 | cut -f 2 -d ' ')" }
fi
unset jenvdir jenvdirs FOUND_JENV
......@@ -7,7 +7,7 @@ _1st_arguments=(
'dashboard:open the dashboard'
'reported:search for issues reported by a user'
'assigned:search for issues assigned to a user'
'br:open the issue named after the git branch of the current directory'
'branch:open the issue named after the git branch of the current directory'
'dumpconfig:display effective jira configuration'
)
......
......@@ -43,7 +43,7 @@ function jira() {
echo "Opening new issue"
open_command "${jira_url}/secure/CreateIssue!default.jspa"
elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
_jira_query $@
_jira_query ${@:-$action}
elif [[ "$action" == "myissues" ]]; then
echo "Opening my issues"
open_command "${jira_url}/issues/?filter=-1"
......
# Jump plugin
This plugin allows to easily jump around the file system by manually adding marks.
Those marks are stored as symbolic links in the directory `$MARKPATH` (default `$HOME/.marks`)
To use it, add `jump` to the plugins array in your zshrc file:
```zsh
plugins=(... jump)
```
## Commands
| Command | Description |
|----------------------|-------------------------------------------------------------------------------------------------|
| `jump <mark-name>` | Jump to the given mark |
| `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided |
| `unmark <mark-name>` | Remove the given mark |
| `marks` | List the existing marks and the directories they point to |
......@@ -19,7 +19,7 @@ mark() {
MARK="$1"
fi
if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then
mkdir -p "$MARKPATH"; ln -s "$PWD" "$MARKPATH/$MARK"
mkdir -p "$MARKPATH"; ln -sfn "$PWD" "$MARKPATH/$MARK"
fi
}
......@@ -28,11 +28,18 @@ unmark() {
}
marks() {
local max=0
for link in $MARKPATH/*(@); do
if [[ ${#link:t} -gt $max ]]; then
max=${#link:t}
fi
done
local printf_markname_template="$(printf -- "%%%us " "$max")"
for link in $MARKPATH/*(@); do
local markname="$fg[cyan]${link:t}$reset_color"
local markpath="$fg[blue]$(readlink $link)$reset_color"
printf "%s\t" $markname
printf "-> %s \t\n" $markpath
printf -- "$printf_markname_template" "$markname"
printf -- "-> %s\n" "$markpath"
done
}
......
# Kate plugin
This plugin adds aliases for the [Kate editor](https://kate-editor.org).
To use it, add kate to the plugins array of your zshrc file:
```
plugins=(... kate)
```
## Aliases
| Alias | Command | Description |
|-------|------------------------|---------------------|
| kate | `kate >/dev/null 2>&1` | Start kate silently |
## Functions
| Function | Description |
|------------|------------------------------------------|
| `kt <dir>` | Change to directory and start kate there |
# keychain plugin
This plugin starts automatically [`keychain`](https://www.funtoo.org/Keychain)
to set up and load whichever credentials you want for both gpg and ssh
connections.
To enable it, add `keychain` to your plugins:
```zsh
plugins=(... keychain)
```
**NOTE**: It is HIGHLY recommended to also enable the `gpg-agent` plugin.
## Instructions
**IMPORTANT: put these settings _before_ the line that sources oh-my-zsh**
**To adjust the agents** that keychain manages, use the `agents` style as
shown below. By default, only the `gpg` agent is managed.
```zsh
zstyle :omz:plugins:keychain agents gpg,ssh
```
To **load multiple identities** use the `identities` style, For example:
```zsh
zstyle :omz:plugins:keychain identities id_ed25519 id_github 2C5879C2
```
**To pass additional options** to the `keychain` program, use the
`options` style; for example:
```zsh
zstyle :omz:plugins:keychain options --quiet
```
## Credits
Based on code from the `ssh-agent` plugin.
## References
- [Keychain](https://www.funtoo.org/Keychain)
function _start_agent() {
local agents
local -a identities
local -a options
local _keychain_env_sh
local _keychain_env_sh_gpg
# load agents to start.
zstyle -s :omz:plugins:keychain agents agents
# load identities to manage.
zstyle -a :omz:plugins:keychain identities identities
# load additional options
zstyle -a :omz:plugins:keychain options options
# start keychain...
keychain ${^options:-} --agents ${agents:-gpg} ${^identities}
# Get the filenames to store/lookup the environment from
_keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh"
_keychain_env_sh_gpg="$HOME/.keychain/$SHORT_HOST-sh-gpg"
# Source environment settings.
[ -f "$_keychain_env_sh" ] && . "$_keychain_env_sh"
[ -f "$_keychain_env_sh_gpg" ] && . "$_keychain_env_sh_gpg"
}
_start_agent
# tidy up after ourselves
unfunction _start_agent
# kitchen plugin
This plugin adds completion support for the [Test Kitchen](https://kitchen.ci).
To use it, add `kitchen` to the plugins array in your zshrc file:
```zsh
plugins=(... kitchen)
```
#compdef kitchen
# ------------------------------------------------------------------------------
# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users
# Copyright (c) 2014 Github zsh-users - https://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
......@@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for Test Kitchen (http://kitchen.ci/).
# Completion script for Test Kitchen (https://kitchen.ci/).
#
# ------------------------------------------------------------------------------
# Authors
......
# kops
This plugin provides completion for [kops](https://github.com/kubernetes/kops) (Kubernetes Operations),
the command line interface to get a production grade Kubernetes cluster up and running.
To use it, add `kops` to the plugins array in your zshrc file.
```
plugins=(... kops)
```
**Author:** [@nmrony](https://github.com/nmrony)
# Autocompletion for kops (Kubernetes Operations),
# the command line interface to get a production grade
# Kubernetes cluster up and running
# Author: https://github.com/nmrony
if [ $commands[kops] ]; then
source <(kops completion zsh)
fi
Kubernetes prompt for zsh
=========================
# Kubernetes prompt for zsh
A Kubernetes (k8s) zsh prompt that displays the current cluster cluster
A Kubernetes zsh prompt that displays the current cluster cluster
and the namespace.
Inspired by several tools used to simplify usage of kubectl
NOTE: If you are not using zsh, check out [kube-ps1](https://github.com/jonmosco/kube-ps1) designed for bash
as well as zsh.
NOTE: If you are not using zsh, check out [kube-ps1](https://github.com/jonmosco/kube-ps1)
designed for bash as well as zsh.
## Requirements
......@@ -32,29 +31,51 @@ fast switching between clusters and namespaces.
The prompt layout is:
```
(<logo>|<cluster>:<namespace>)
(<symbol>|<cluster>:<namespace>)
```
Supported platforms:
* k8s - Kubernetes
* ocp - OpenShift
## Enabling
## Install
In order to use kube-ps1 with Oh My Zsh, you'll need to enable them in the
.zshrc file. You'll find the zshrc file in your $HOME directory. Open it with
your favorite text editor and you'll see a spot to list all the plugins you
want to load.
1. Clone this repository
2. Source the kube-ps1.zsh in your ~./.zshrc
```shell
vim $HOME/.zshrc
```
Add kube-ps1 to the list of enabled plugins and enable it on the prompt:
```shell
plugins=(
git
kube-ps1
)
ZSH:
PROMPT=$PROMPT'$(kube_ps1) '
```
source path/kube-ps1.sh
PROMPT='$(kube_ps1) '
Note: the `PROMPT` example above was tested with the theme `robbyrussell`
## Enabling / Disabling on the current shell
Sometimes the kubernetes information can be anoying, you can easily
switch it on and off with the following commands:
```shell
kubeon
```
```shell
kubeoff
```
## Colors
The colors are of my opinion. Blue was used as the prefix to match the Kubernetes
color as closely as possible. Red was chosen as the cluster name to stand out, and cyan
for the namespace. These can of course be changed.
Blue was used as the prefix to match the Kubernetes color as closely as
possible. Red was chosen as the cluster name to stand out, and cyan
for the namespace. Check the customization section for changing them.
## Customization
......@@ -62,15 +83,21 @@ The default settings can be overridden in ~/.zshrc
| Variable | Default | Meaning |
| :------- | :-----: | ------- |
| `KUBE_PS1_DEFAULT` | `true` | Default settings for the prompt |
| `KUBE_PS1_BINARY` | `kubectl` | Default Kubernetes binary |
| `KUBE_PS1_PREFIX` | `(` | Prompt opening character |
| `KUBE_PS1_DEFAULT_LABEL` | `⎈ ` | Default prompt symbol |
| `KUBE_PS1_SYMBOL_ENABLE` | `true ` | Display the prompt Symbol. If set to `false`, this will also disable `KUBE_PS1_SEPARATOR` |
| `KUBE_PS1_SYMBOL_DEFAULT` | `⎈ ` | Default prompt symbol. Unicode `\u2388` |
| `KUBE_PS1_SYMBOL_USE_IMG` | `false` | ☸️ , Unicode `\u2638` as the prompt symbol |
| `KUBE_PS1_NS_ENABLE` | `true` | Display the namespace. If set to `false`, this will also disable `KUBE_PS1_DIVIDER` |
| `KUBE_PS1_SEPERATOR` | `\|` | Separator between symbol and cluster name |
| `KUBE_PS1_PLATFORM` | `kubectl` | Cluster type and binary to use |
| `KUBE_PS1_DIVIDER` | `:` | Separator between cluster and namespace |
| `KUBE_PS1_SUFFIX` | `)` | Prompt closing character |
| `KUBE_PS1_DEFAULT_LABEL_IMG` | `false` | Use Kubernetes img as the label: ☸️ |
| `KUBE_PS1_COLOR_SYMBOL` | `"%F{blue}"` | Custom color for the symbol |
| `KUBE_PS1_COLOR_CONTEXT` | `"%F{red}"` | Custom color for the context |
| `KUBE_PS1_COLOR_NS` | `"%F{cyan}"` | Custom color for the namespace |
| `KUBE_PS1_ENABLED` | `true` | Set to false to start disabled on any new shell, `kubeon`/`kubeoff` will flip this value on the current shell |
## Contributors
Jared Yanovich
- Jared Yanovich
- Pedro Moranga
\ No newline at end of file
#!/bin/zsh
# Kubernetes prompt helper for bash/zsh
# ported to oh-my-zsh
# Displays current context and namespace
# Copyright 2017 Jon Mosco
# Copyright 2018 Jon Mosco
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
......@@ -21,32 +22,44 @@
[[ -n $DEBUG ]] && set -x
setopt PROMPT_SUBST
add-zsh-hook precmd _kube_ps1_load
autoload -U add-zsh-hook
add-zsh-hook precmd _kube_ps1_update_cache
zmodload zsh/stat
zmodload zsh/datetime
# Default values for the prompt
# Override these values in ~/.zshrc or ~/.bashrc
KUBE_PS1_DEFAULT="${KUBE_PS1_DEFAULT:=true}"
KUBE_PS1_PREFIX="("
KUBE_PS1_DEFAULT_LABEL="${KUBE_PS1_DEFAULT_LABEL:="⎈ "}"
KUBE_PS1_DEFAULT_LABEL_IMG="${KUBE_PS1_DEFAULT_LABEL_IMG:=false}"
KUBE_PS1_SEPERATOR="|"
KUBE_PS1_PLATFORM="${KUBE_PS1_PLATFORM:="kubectl"}"
KUBE_PS1_DIVIDER=":"
KUBE_PS1_SUFFIX=")"
KUBE_PS1_UNAME=$(uname)
# Override these values in ~/.zshrc
KUBE_PS1_BINARY="${KUBE_PS1_BINARY:-kubectl}"
KUBE_PS1_SYMBOL_ENABLE="${KUBE_PS1_SYMBOL_ENABLE:-true}"
KUBE_PS1_SYMBOL_DEFAULT="${KUBE_PS1_SYMBOL_DEFAULT:-\u2388 }"
KUBE_PS1_SYMBOL_USE_IMG="${KUBE_PS1_SYMBOL_USE_IMG:-false}"
KUBE_PS1_NS_ENABLE="${KUBE_PS1_NS_ENABLE:-true}"
KUBE_PS1_SEPARATOR="${KUBE_PS1_SEPARATOR-|}"
KUBE_PS1_DIVIDER="${KUBE_PS1_DIVIDER-:}"
KUBE_PS1_PREFIX="${KUBE_PS1_PREFIX-(}"
KUBE_PS1_SUFFIX="${KUBE_PS1_SUFFIX-)}"
KUBE_PS1_LAST_TIME=0
KUBE_PS1_ENABLED=true
kube_ps1_label () {
KUBE_PS1_COLOR_SYMBOL="%F{blue}"
KUBE_PS1_COLOR_CONTEXT="%F{red}"
KUBE_PS1_COLOR_NS="%F{cyan}"
[[ "${KUBE_PS1_DEFAULT_LABEL_IMG}" == false ]] && return
_kube_ps1_binary_check() {
command -v "$1" >/dev/null
}
if [[ "${KUBE_PS1_DEFAULT_LABEL_IMG}" == true ]]; then
local KUBE_LABEL="☸️ "
fi
_kube_ps1_symbol() {
[[ "${KUBE_PS1_SYMBOL_ENABLE}" == false ]] && return
KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}"
KUBE_PS1_SYMBOL_IMG="\u2638 "
KUBE_PS1_DEFAULT_LABEL="${KUBE_LABEL}"
if [[ "${KUBE_PS1_SYMBOL_USE_IMG}" == true ]]; then
KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_IMG}"
fi
echo "${KUBE_PS1_SYMBOL}"
}
_kube_ps1_split() {
......@@ -56,23 +69,45 @@ _kube_ps1_split() {
}
_kube_ps1_file_newer_than() {
local mtime
local file=$1
local check_time=$2
mtime=$(stat +mtime "${file}")
[ "${mtime}" -gt "${check_time}" ]
zmodload -e "zsh/stat"
if [[ "$?" -eq 0 ]]; then
mtime=$(stat +mtime "${file}")
elif stat -c "%s" /dev/null &> /dev/null; then
# GNU stat
mtime=$(stat -c %Y "${file}")
else
# BSD stat
mtime=$(stat -f %m "$file")
fi
[[ "${mtime}" -gt "${check_time}" ]]
}
_kube_ps1_load() {
# kubectl will read the environment variable $KUBECONFIG
# otherwise set it to ~/.kube/config
_kube_ps1_update_cache() {
KUBECONFIG="${KUBECONFIG:=$HOME/.kube/config}"
if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
# No ability to fetch context/namespace; display N/A.
KUBE_PS1_CONTEXT="BINARY-N/A"
KUBE_PS1_NAMESPACE="N/A"
return
fi
for conf in $(_kube_ps1_split : "${KUBECONFIG}"); do
# TODO: check existence of $conf
if [[ "${KUBECONFIG}" != "${KUBE_PS1_KUBECONFIG_CACHE}" ]]; then
# User changed KUBECONFIG; unconditionally refetch.
KUBE_PS1_KUBECONFIG_CACHE=${KUBECONFIG}
_kube_ps1_get_context_ns
return
fi
# kubectl will read the environment variable $KUBECONFIG
# otherwise set it to ~/.kube/config
local conf
for conf in $(_kube_ps1_split : "${KUBECONFIG:-${HOME}/.kube/config}"); do
[[ -r "${conf}" ]] || continue
if _kube_ps1_file_newer_than "${conf}" "${KUBE_PS1_LAST_TIME}"; then
_kube_ps1_get_context_ns
return
......@@ -83,41 +118,42 @@ _kube_ps1_load() {
_kube_ps1_get_context_ns() {
# Set the command time
KUBE_PS1_LAST_TIME=$(date +%s)
if [[ "${KUBE_PS1_DEFAULT}" == true ]]; then
local KUBE_BINARY="${KUBE_PS1_PLATFORM}"
elif [[ "${KUBE_PS1_DEFAULT}" == false ]] && [[ "${KUBE_PS1_PLATFORM}" == "kubectl" ]];then
local KUBE_BINARY="kubectl"
elif [[ "${KUBE_PS1_PLATFORM}" == "oc" ]]; then
local KUBE_BINARY="oc"
fi
KUBE_PS1_LAST_TIME=$EPOCHSECONDS
KUBE_PS1_CONTEXT="$(${KUBE_BINARY} config current-context)"
KUBE_PS1_NAMESPACE="$(${KUBE_BINARY} config view --minify --output 'jsonpath={..namespace}')"
# Set namespace to default if it is not defined
KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)"
if [[ -z "${KUBE_PS1_CONTEXT}" ]]; then
KUBE_PS1_CONTEXT="N/A"
KUBE_PS1_NAMESPACE="N/A"
return
elif [[ "${KUBE_PS1_NS_ENABLE}" == true ]]; then
KUBE_PS1_NAMESPACE="$(${KUBE_PS1_BINARY} config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)"
# Set namespace to 'default' if it is not defined
KUBE_PS1_NAMESPACE="${KUBE_PS1_NAMESPACE:-default}"
fi
}
# function to disable the prompt on the current shell
kubeon(){
KUBE_PS1_ENABLED=true
}
# source our symbol
kube_ps1_label
# function to disable the prompt on the current shell
kubeoff(){
KUBE_PS1_ENABLED=false
}
# Build our prompt
kube_ps1 () {
local reset_color="%f"
local blue="%F{blue}"
local red="%F{red}"
local cyan="%F{cyan}"
local reset_color="%{$reset_color%}"
[[ ${KUBE_PS1_ENABLED} != 'true' ]] && return
KUBE_PS1="${reset_color}$KUBE_PS1_PREFIX"
KUBE_PS1+="${blue}$KUBE_PS1_DEFAULT_LABEL"
KUBE_PS1+="${KUBE_PS1_COLOR_SYMBOL}$(_kube_ps1_symbol)"
KUBE_PS1+="${reset_color}$KUBE_PS1_SEPERATOR"
KUBE_PS1+="${red}$KUBE_PS1_CONTEXT${reset_color}"
KUBE_PS1+="${KUBE_PS1_COLOR_CONTEXT}$KUBE_PS1_CONTEXT${reset_color}"
KUBE_PS1+="$KUBE_PS1_DIVIDER"
KUBE_PS1+="${cyan}$KUBE_PS1_NAMESPACE${reset_color}"
KUBE_PS1+="${KUBE_PS1_COLOR_NS}$KUBE_PS1_NAMESPACE${reset_color}"
KUBE_PS1+="$KUBE_PS1_SUFFIX"
echo "${KUBE_PS1}"
}
# Kubectl plugin
This plugin adds completion for the [Kubernetes cluster manager](https://kubernetes.io/docs/reference/kubectl/kubectl/),
as well as some aliases for common kubectl commands.
To use it, add `kubectl` to the plugins array in your zshrc file:
```zsh
plugins=(... kubectl)
```
## Aliases
| Alias | Command | Description |
|:--------|:------------------------------------|:-------------------------------------------------------------------------------------------------|
| k | `kubectl` | The kubectl command |
| kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces |
| kaf | `kubectl apply -f` | Apply a YML file |
| keti | `kubectl exec -ti` | Drop into an interactive terminal on a container |
| | | **Manage configuration quickly to switch contexts between local, dev and staging** |
| kcuc | `kubectl config use-context` | Set the current-context in a kubeconfig file |
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
| kccc | `kubectl config current-context` | Display the current-context |
| | | **General aliases** |
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
| kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
| | | **Pod management** |
| kgp | `kubectl get pods` | List all pods in ps output format |
| kgpw | `kgp --watch` | After listing/getting the requested object, watch for changes |
| kgpwide | `kgp -o wide` | Output in plain-text format with any additional information. For pods, the node name is included |
| kep | `kubectl edit pods` | Edit pods from the default editor |
| kdp | `kubectl describe pods` | Describe all pods |
| kdelp | `kubectl delete pods` | Delete all pods matching passed arguments |
| kgpl | `kgp -l` | Get pod by label. Example: `kgpl "app=myapp" -n myns` |
| | | **Service management** |
| kgs | `kubectl get svc` | List all services in ps output format |
| kgsw | `kgs --watch` | After listing all services, watch for changes |
| kgswide | `kgs -o wide` | After listing all services, output in plain-text format with any additional information |
| kes | `kubectl edit svc` | Edit services(svc) from the default editor |
| kds | `kubectl describe svc` | Describe all services in detail |
| kdels | `kubectl delete svc` | Delete all services matching passed argument |
| | | **Ingress management** |
| kgi | `kubectl get ingress` | List ingress resources in ps output format |
| kei | `kubectl edit ingress` | Edit ingress resource from the default editor |
| kdi | `kubectl describe ingress` | Describe ingress resource in detail |
| kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument |
| | | **Namespace management** |
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
| kcn | `kubectl config set-context ...` | Change current namespace |
| kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
| kdns | `kubectl describe namespace` | Describe namespace resource in detail |
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
| | | **ConfigMap management** |
| kgcm | `kubectl get configmaps` | List the configmaps in ps output format |
| kecm | `kubectl edit configmap` | Edit configmap resource from the default editor |
| kdcm | `kubectl describe configmap` | Describe configmap resource in detail |
| kdelcm | `kubectl delete configmap` | Delete the configmap |
| | | **Secret management** |
| kgsec | `kubectl get secret` | Get secret for decoding |
| kdsec | `kubectl describe secret` | Describe secret resource in detail |
| kdelsec | `kubectl delete secret` | Delete the secret |
| | | **Deployment management** |
| kgd | `kubectl get deployment` | Get the deployment |
| kgdw | `kgd --watch` | After getting the deployment, watch for changes |
| kgdwide | `kgd -o wide` | After getting the deployment, output in plain-text format with any additional information |
| ked | `kubectl edit deployment` | Edit deployment resource from the default editor |
| kdd | `kubectl describe deployment` | Describe deployment resource in detail |
| kdeld | `kubectl delete deployment` | Delete the deployment |
| ksd | `kubectl scale deployment` | Scale a deployment |
| krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment |
| kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
| | | **Rollout management** |
| kgrs | `kubectl get rs` | To see the ReplicaSet `rs` created by the deployment |
| krh | `kubectl rollout history` | Check the revisions of this deployment |
| kru | `kubectl rollout undo` | Rollback to the previous revision |
| | | **Port forwarding** |
| kpf | `kubectl port-forward` | Forward one or more local ports to a pod |
| | | **Tools for accessing all information** |
| kga | `kubectl get all` | List all resources in ps format |
| kgaa | `kubectl get all --all-namespaces` | List the requested object(s) across all namespaces |
| | | **Logs** |
| kl | `kubectl logs` | Print the logs for a container or resource |
| klf | `kubectl logs -f` | Stream the logs for a container or resource (follow) |
| | | **File copy** |
| kcp | `kubectl cp` | Copy files and directories to and from containers |
| | | **Node management** |
| kgno | `kubectl get nodes` | List the nodes in ps output format |
| keno | `kubectl edit node` | Edit nodes resource from the default editor |
| kdno | `kubectl describe node` | Describe node resource in detail |
| kdelno | `kubectl delete node` | Delete the node |
# Autocompletion for kubectl, the command line interface for Kubernetes
#
# Author: https://github.com/pstadler
if (( $+commands[kubectl] )); then
__KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
if [ $commands[kubectl] ]; then
source <(kubectl completion zsh)
if [[ ! -f $__KUBECTL_COMPLETION_FILE ]]; then
kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
fi
[[ -f $__KUBECTL_COMPLETION_FILE ]] && source $__KUBECTL_COMPLETION_FILE
unset __KUBECTL_COMPLETION_FILE
fi
# This command is used ALOT both below and in daily life
# This command is used a LOT both below and in daily life
alias k=kubectl
# Execute a kubectl command against all namespaces
alias kca='f(){ kubectl "$@" --all-namespaces; unset -f f; }; f'
# Apply a YML file
alias kaf='k apply -f'
alias kaf='kubectl apply -f'
# Drop into an interactive terminal on a container
alias keti='k exec -ti'
alias keti='kubectl 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'
alias kcuc='kubectl config use-context'
alias kcsc='kubectl config set-context'
alias kcdc='kubectl config delete-context'
alias kccc='kubectl config current-context'
# General aliases
alias kdel='kubectl delete'
alias kdelf='kubectl delete -f'
# Pod management.
alias kgp='k get pods'
alias kep='k edit pods'
alias kdp='k describe pods'
alias kdelp='k delete pods'
alias kgp='kubectl get pods'
alias kgpw='kgp --watch'
alias kgpwide='kgp -o wide'
alias kep='kubectl edit pods'
alias kdp='kubectl describe pods'
alias kdelp='kubectl delete pods'
# get pod by label: kgpl "app=myapp" -n myns
alias kgpl='kgp -l'
# Service management.
alias kgs='k get svc'
alias kes='k edit svc'
alias kds='k describe svc'
alias kdels='k delete svc'
alias kgs='kubectl get svc'
alias kgsw='kgs --watch'
alias kgswide='kgs -o wide'
alias kes='kubectl edit svc'
alias kds='kubectl describe svc'
alias kdels='kubectl delete svc'
# Ingress management
alias kgi='kubectl get ingress'
alias kei='kubectl edit ingress'
alias kdi='kubectl describe ingress'
alias kdeli='kubectl delete ingress'
# Namespace management
alias kgns='kubectl get namespaces'
alias kens='kubectl edit namespace'
alias kdns='kubectl describe namespace'
alias kdelns='kubectl delete namespace'
alias kcn='kubectl config set-context $(kubectl config current-context) --namespace'
# ConfigMap management
alias kgcm='kubectl get configmaps'
alias kecm='kubectl edit configmap'
alias kdcm='kubectl describe configmap'
alias kdelcm='kubectl delete configmap'
# Secret management
alias kgsec='k get secret'
alias kdsec='k describe secret'
alias kdelsec='k delete secret'
alias kgsec='kubectl get secret'
alias kdsec='kubectl describe secret'
alias kdelsec='kubectl 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'
alias kgd='kubectl get deployment'
alias kgdw='kgd --watch'
alias kgdwide='kgd -o wide'
alias ked='kubectl edit deployment'
alias kdd='kubectl describe deployment'
alias kdeld='kubectl delete deployment'
alias ksd='kubectl scale deployment'
alias krsd='kubectl rollout status deployment'
kres(){
kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S)
}
# Rollout management.
alias kgrs='k get rs'
alias krh='k rollout history'
alias kru='k rollout undo'
alias kgrs='kubectl get rs'
alias krh='kubectl rollout history'
alias kru='kubectl rollout undo'
# Port forwarding
alias kpf="kubectl port-forward"
# Tools for accessing all information
alias kga='kubectl get all'
alias kgaa='kubectl get all --all-namespaces'
# Logs
alias kl='k logs'
alias klf='k logs -f'
alias kl='kubectl logs'
alias klf='kubectl logs -f'
# File copy
alias kcp='kubectl cp'
# Node Management
alias kgno='kubectl get nodes'
alias keno='kubectl edit node'
alias kdno='kubectl describe node'
alias kdelno='kubectl delete node'
# Laravel
This plugin adds aliases and autocompletion for Laravel [Artisan](https://laravel.com/docs/artisan) and [Bob](http://daylerees.github.io/laravel-bob/) command-line interfaces.
```
plugins=(... laravel)
```
| Alias | Description |
|:-:|:-:|
| `artisan` | `php artisan` |
| `pas` | `php artisan serve` |
## Database
| Alias | Description |
|:-:|:-:|
| `pam` | `php artisan migrate` |
| `pamf` | `php artisan migrate:fresh` |
| `pamfs` | `php artisan migrate:fresh --seed` |
| `pamr` | `php artisan migrate:rollback` |
| `pads` | `php artisan db:seed` |
## Makers
| Alias | Description |
|:-:|:-:|
| `pamm` | `php artisan make:model` |
| `pamc` | `php artisan make:controller` |
| `pams` | `php artisan make:seeder` |
| `pamt` | `php artisan make:test` |
## Clears
| Alias | Description |
|:-:|:-:|
| `pacac` | `php artisan cache:clear` |
| `pacoc` | `php artisan config:clear` |
| `pavic` | `php artisan view:clear` |
| `paroc` | `php artisan route:clear` |
#!zsh
alias artisan='php artisan'
alias bob='php artisan bob::build'
# Development
alias pas='php artisan serve'
# Database
alias pam='php artisan migrate'
alias pamf='php artisan migrate:fresh'
alias pamfs='php artisan migrate:fresh --seed'
alias pamr='php artisan migrate:rollback'
alias pads='php artisan db:seed'
# Makers
alias pamm='php artisan make:model'
alias pamc='php artisan make:controller'
alias pams='php artisan make:seeder'
alias pamt='php artisan make:test'
# Clears
alias pacac='php artisan cache:clear'
alias pacoc='php artisan config:clear'
alias pavic='php artisan view:clear'
alias paroc='php artisan route:clear'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment