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

Merge branch 'master' into fabric_task_description

parents 225425fe 40df67bc
# 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)
if [ $commands[kops] ]; then
source <(kops completion zsh)
fi
# Kubernetes prompt for zsh
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.
## Requirements
The default prompt assumes you have the kubectl command line utility installed. It
can be obtained here:
[Install and Set up kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
If using this with OpenShift, the oc tool needs installed. It can be obtained from here:
[OC Client Tools](https://www.openshift.org/download.html)
## Helper utilities
There are several great tools that make using kubectl very enjoyable.
[kubectx and kubenx](https://github.com/ahmetb/kubectx) are great for
fast switching between clusters and namespaces.
## Prompt Structure
The prompt layout is:
```
(<symbol>|<cluster>:<namespace>)
```
## Enabling
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.
```shell
vim $HOME/.zshrc
```
Add kube-ps1 to the list of enabled plugins and enable it on the prompt:
```shell
plugins=(
git
kube-ps1
)
# After the "source Oh My Zsh" line
PROMPT=$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
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
The default settings can be overridden in ~/.zshrc
| Variable | Default | Meaning |
| :------- | :-----: | ------- |
| `KUBE_PS1_BINARY` | `kubectl` | Default Kubernetes binary |
| `KUBE_PS1_PREFIX` | `(` | Prompt opening character |
| `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_DIVIDER` | `:` | Separator between cluster and namespace |
| `KUBE_PS1_SUFFIX` | `)` | Prompt closing character |
| `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
- Pedro Moranga
#!/bin/zsh
# Kubernetes prompt helper for bash/zsh
# ported to oh-my-zsh
# Displays current context and namespace
# 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
#
# 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,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Debug
[[ -n $DEBUG ]] && set -x
setopt PROMPT_SUBST
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
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_COLOR_SYMBOL="%{$fg[blue]%}"
KUBE_PS1_COLOR_CONTEXT="%{$fg[red]%}"
KUBE_PS1_COLOR_NS="%{$fg[cyan]%}"
_kube_ps1_binary_check() {
command -v "$1" >/dev/null
}
_kube_ps1_symbol() {
[[ "${KUBE_PS1_SYMBOL_ENABLE}" == false ]] && return
KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}"
KUBE_PS1_SYMBOL_IMG="\u2638 "
if [[ "${KUBE_PS1_SYMBOL_USE_IMG}" == true ]]; then
KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_IMG}"
fi
echo "${KUBE_PS1_SYMBOL}"
}
_kube_ps1_split() {
type setopt >/dev/null 2>&1 && setopt SH_WORD_SPLIT
local IFS=$1
echo $2
}
_kube_ps1_file_newer_than() {
local mtime
local file=$1
local check_time=$2
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_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
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
fi
done
}
_kube_ps1_get_context_ns() {
# Set the command time
KUBE_PS1_LAST_TIME=$EPOCHSECONDS
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
}
# function to disable the prompt on the current shell
kubeoff(){
KUBE_PS1_ENABLED=false
}
# Build our prompt
kube_ps1 () {
local reset_color="%{$reset_color%}"
[[ ${KUBE_PS1_ENABLED} != 'true' ]] && return
KUBE_PS1="${reset_color}$KUBE_PS1_PREFIX"
KUBE_PS1+="${KUBE_PS1_COLOR_SYMBOL}$(_kube_ps1_symbol)"
KUBE_PS1+="${reset_color}$KUBE_PS1_SEPERATOR"
KUBE_PS1+="${KUBE_PS1_COLOR_CONTEXT}$KUBE_PS1_CONTEXT${reset_color}"
KUBE_PS1+="$KUBE_PS1_DIVIDER"
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 |
| kcgc | `kubectl config get-contexts` | List of contexts available
| | | **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 |
| | | **Persistent Volume Claim management** |
| kgpvc | `kubectl get pvc` | List all PVCs |
| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
| kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
| kdpvc | `kubectl describe pvc` | Descirbe all pvcs |
| kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
| | | |
| kgss | `kubectl get statefulset` | List the statefulsets in ps format |
| kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
| kgsswide| `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
| kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor |
| kdss | `kubectl describe statefulset` | Describe statefulset resource in detail |
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
| ksss | `kubectl scale statefulset` | Scale a statefulset |
| krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment |
# 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 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='kubectl apply -f'
# Drop into an interactive terminal on a container
alias keti='kubectl exec -ti'
# Manage configuration quickly to switch contexts between local, dev ad staging.
alias kcuc='kubectl config use-context'
alias kcsc='kubectl config set-context'
alias kcdc='kubectl config delete-context'
alias kccc='kubectl config current-context'
# List all contexts
alias kcgc='kubectl config get-contexts'
# General aliases
alias kdel='kubectl delete'
alias kdelf='kubectl delete -f'
# Pod management.
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='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='kubectl get secret'
alias kdsec='kubectl describe secret'
alias kdelsec='kubectl delete secret'
# Deployment management.
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='kubectl get rs'
alias krh='kubectl rollout history'
alias kru='kubectl rollout undo'
# Statefulset management.
alias kgss='kubectl get statefulset'
alias kgssw='kgss --watch'
alias kgsswide='kgss -o wide'
alias kess='kubectl edit statefulset'
alias kdss='kubectl describe statefulset'
alias kdelss='kubectl delete statefulset'
alias ksss='kubectl scale statefulset'
alias krsss='kubectl rollout status statefulset'
# 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='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'
# PVC management.
alias kgpvc='kubectl get pvc'
alias kgpvcw='kgpvc --watch'
alias kepvc='kubectl edit pvc'
alias kdpvc='kubectl describe pvc'
alias kdelpvc='kubectl delete pvc'
# 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'
# Laravel 4 plugin
This plugin adds some aliases for common [Laravel 4](https://laravel.com/docs/4.2) commands.
To use it, add `laravel4` to the plugins array in your zshrc file:
```zsh
plugins=(... laravel4)
```
## Aliases
| Alias | Command | Description |
|-----------|-------------------------------------------|-------------------------------------------------------------|
| la4 | `php artisan` | Main Artisan command |
| la4dump | `php artisan dump-autoload` | Regenerate framework autoload files |
| la4cache | `php artisan cache:clear` | Flush the application cache |
| la4routes | `php artisan routes` | List all registered routes |
# Laravel 5 plugin
This plugin adds some aliases for common [Laravel 5](https://laravel.com/docs) commands.
To use it, add `laravel5` to the plugins array in your zshrc file:
```zsh
plugins=(... laravel5)
```
## Aliases
| Alias | Command | Description |
|-----------|------------------------------|----------------------------------------------------|
| la5 | `php artisan` | Main Artisan command |
| la5cache | `php artisan cache:clear` | Flush the application cache |
| la5routes | `php artisan route:list` | List all registered routes |
| la5vendor | `php artisan vendor:publish` | Publish any publishable assets from vendor package |
# Laravel5 basic command completion
_laravel5_get_command_list () {
php artisan --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z]+/ { print $1 }'
php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"
}
_laravel5 () {
......
# last-working-dir plugin
Keeps track of the last used working directory and automatically jumps into it
for new shells, unless:
- The plugin is already loaded.
- The current `$PWD` is not `$HOME`.
Adds `lwd` function to jump to the last working directory.
#!/usr/bin/env zsh
# Keeps track of the last used working directory and automatically jumps
# into it for new shells.
# Flag indicating if we've previously jumped to last directory.
# Flag indicating if we've previously jumped to last directory
typeset -g ZSH_LAST_WORKING_DIRECTORY
mkdir -p $ZSH_CACHE_DIR
cache_file="$ZSH_CACHE_DIR/last-working-dir"
# Updates the last directory once directory is changed.
# Updates the last directory once directory is changed
chpwd_functions+=(chpwd_last_working_dir)
function chpwd_last_working_dir() {
# Use >| in case noclobber is set to avoid "file exists" error
pwd >| "$cache_file"
chpwd_last_working_dir() {
if [ "$ZSH_SUBSHELL" = 0 ]; then
local cache_file="$ZSH_CACHE_DIR/last-working-dir"
pwd >| "$cache_file"
fi
}
# Changes directory to the last working directory.
function lwd() {
[[ ! -r "$cache_file" ]] || cd "`cat "$cache_file"`"
# Changes directory to the last working directory
lwd() {
local cache_file="$ZSH_CACHE_DIR/last-working-dir"
[[ -r "$cache_file" ]] && cd "$(cat "$cache_file")"
}
# Automatically jump to last working directory unless this isn't the first time
# this plugin has been loaded.
if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then
lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true
fi
# Jump to last directory automatically unless:
# - this isn't the first time the plugin is loaded
# - it's not in $HOME directory
[[ -n "$ZSH_LAST_WORKING_DIRECTORY" ]] && return
[[ "$PWD" != "$HOME" ]] && return
lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true
# Leiningen plugin
This plugin adds completions for the [Leiningen](https://leiningen.org/) Clojure build tool.
To use it, add `lein` to the plugins array in your zshrc file:
```zsh
plugins=(... lein)
```
#compdef lein
# Lein ZSH completion function
# Drop this somewhere in your $fpath (like /usr/share/zsh/site-functions)
# and rename it _lein
_lein() {
if (( CURRENT > 2 )); then
# shift words so _arguments doesn't have to be concerned with second command
(( CURRENT-- ))
shift words
# use _call_function here in case it doesn't exist
_call_function 1 _lein_${words[1]}
else
_values "lein command" \
"change[Rewrite project.clj by applying a function.]" \
"check[Check syntax and warn on reflection.]" \
"classpath[Print the classpath of the current project.]" \
"clean[Remove all files from project's target-path.]" \
"compile[Compile Clojure source into .class files.]" \
"deploy[Build and deploy jar to remote repository.]" \
"deps[Download all dependencies.]" \
"do[Higher-order task to perform other tasks in succession.]" \
"help[Display a list of tasks or help for a given task.]" \
"install[Install the current project to the local repository.]" \
"jar[Package up all the project's files into a jar file.]" \
"javac[Compile Java source files.]" \
"new[Generate project scaffolding based on a template.]" \
"plugin[DEPRECATED. Please use the :user profile instead.]" \
"pom[Write a pom.xml file to disk for Maven interoperability.]" \
"release[Perform :release-tasks.]" \
"repl[Start a repl session either with the current project or standalone.]" \
"retest[Run only the test namespaces which failed last time around.]" \
"run[Run a -main function with optional command-line arguments.]" \
"search[Search remote maven repositories for matching jars.]" \
"show-profiles[List all available profiles or display one if given an argument.]" \
"test[Run the project's tests.]" \
"trampoline[Run a task without nesting the project's JVM inside Leiningen's.]" \
"uberjar[Package up the project files and dependencies into a jar file.]" \
"update-in[Perform arbitrary transformations on your project map.]" \
"upgrade[Upgrade Leiningen to specified version or latest stable.]" \
"vcs[Interact with the version control system.]" \
"version[Print version for Leiningen and the current JVM.]" \
"with-profile[Apply the given task with the profile(s) specified.]"
fi
}
_lein_plugin() {
_values "lein plugin commands" \
"install[Download, package, and install plugin jarfile into ~/.lein/plugins]" \
"uninstall[Delete the plugin jarfile: \[GROUP/\]ARTIFACT-ID VERSION]"
}
_lein_namespaces() {
if [ -f "./project.clj" -a -d "$1" ]; then
_values "lein valid namespaces" \
$(find "$1" -type f -name "*.clj" -exec awk '/^\(ns */ {gsub("\\)", "", $2); print $2}' '{}' '+')
fi
}
_lein_run() {
_lein_namespaces "src/"
}
_lein_test() {
_lein_namespaces "test/"
}
function _lein_commands() {
local ret=1 state
_arguments ':subcommand:->subcommand' && ret=0
case $state in
subcommand)
subcommands=(
"classpath:print the classpath of the current project"
"clean:remove compiled files and dependencies from project"
"compile:ahead-of-time compile the project"
"deploy:build jar and deploy to remote repository"
"deps:download and install all dependencies"
"help:display a list of tasks or help for a given task"
"install:install the project and its dependencies in your local repository"
"int:enter an interactive task shell"
"interactive:enter an interactive task shell"
"jack-in:jack in to a clojure slime session from emacs."
"jar:create a jar file containing the compiled .class files"
"javac:compile java source files"
"new:create a new project skeleton"
"plugin:manage user-level plugins"
"pom:write a pom.xml file to disk for maven interop"
"repl:start a repl session either with the current project or standalone"
"retest:run only the test namespaces which failed last time around"
"run:run the project's -main function"
"search:search remote maven repositories for matching jars"
"swank:launch swank server for Emacs to connect"
"test:run the project's tests"
"test!:run a project's tests after cleaning and fetching dependencies"
"trampoline:run a task without nesting the project's JVM inside Leiningen's."
"uberjar:Create a jar including the contents of each of deps"
"upgrade:upgrade leiningen to the latest stable release"
"version:print leiningen's version"
)
_describe -t subcommands 'leiningen subcommands' subcommands && ret=0
;;
*) _files
esac
return ret
}
compdef _lein_commands lein
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