Unverified Commit 8c95c523 authored by Kozlov Alexander's avatar Kozlov Alexander Committed by GitHub
Browse files

Merge branch 'master' into master

parents dd30cf10 3d8f2bda
...@@ -60,7 +60,7 @@ function jira() { ...@@ -60,7 +60,7 @@ function jira() {
else else
# Anything that doesn't match a special action is considered an issue name # Anything that doesn't match a special action is considered an issue name
# but `branch` is a special case that will parse the current git branch # but `branch` is a special case that will parse the current git branch
if [[ "$action" == "br" ]]; then if [[ "$action" == "branch" ]]; then
local issue_arg=$(git rev-parse --abbrev-ref HEAD) local issue_arg=$(git rev-parse --abbrev-ref HEAD)
local issue="${jira_prefix}${issue_arg}" local issue="${jira_prefix}${issue_arg}"
else else
......
# 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() { ...@@ -19,7 +19,7 @@ mark() {
MARK="$1" MARK="$1"
fi fi
if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then 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 fi
} }
...@@ -32,7 +32,7 @@ marks() { ...@@ -32,7 +32,7 @@ marks() {
local markname="$fg[cyan]${link:t}$reset_color" local markname="$fg[cyan]${link:t}$reset_color"
local markpath="$fg[blue]$(readlink $link)$reset_color" local markpath="$fg[blue]$(readlink $link)$reset_color"
printf "%s\t" $markname printf "%s\t" $markname
printf "-> %s \t\n" $markpath printf -- "-> %s \t\n" $markpath
done 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 |
# 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 #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. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
# Description # Description
# ----------- # -----------
# #
# Completion script for Test Kitchen (http://kitchen.ci/). # Completion script for Test Kitchen (https://kitchen.ci/).
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Authors # 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 if [ $commands[kops] ]; then
source <(kops completion zsh) source <(kops completion zsh)
fi 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:
```shell
plugins=(
git
kube-ps1
)
```
## 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. These can of course be changed.
## 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 |
## Contributors
Jared Yanovich
#!/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_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
}
# Build our prompt
kube_ps1 () {
local reset_color="%f"
local blue="%F{blue}"
local red="%F{red}"
local cyan="%F{cyan}"
KUBE_PS1="${reset_color}$KUBE_PS1_PREFIX"
KUBE_PS1+="${blue}$(_kube_ps1_symbol)"
KUBE_PS1+="${reset_color}$KUBE_PS1_SEPERATOR"
KUBE_PS1+="${red}$KUBE_PS1_CONTEXT${reset_color}"
KUBE_PS1+="$KUBE_PS1_DIVIDER"
KUBE_PS1+="${cyan}$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 |
| 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 |
| 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 |
| | | **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 if (( $+commands[kubectl] )); then
# __KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
# Author: https://github.com/pstadler
if [ $commands[kubectl] ]; then if [[ ! -f $__KUBECTL_COMPLETION_FILE ]]; then
source <(kubectl completion zsh) kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
fi
[[ -f $__KUBECTL_COMPLETION_FILE ]] && source $__KUBECTL_COMPLETION_FILE
unset __KUBECTL_COMPLETION_FILE
fi 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 alias k=kubectl
# Apply a YML file
alias kaf='kubectl apply -f'
# Drop into an interactive terminal on a container # 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. # Manage configuration quickly to switch contexts between local, dev ad staging.
alias kcuc='k config use-context' alias kcuc='kubectl config use-context'
alias kcsc='k config set-context' alias kcsc='kubectl config set-context'
alias kcdc='k config delete-context' alias kcdc='kubectl config delete-context'
alias kccc='k config current-context' alias kccc='kubectl config current-context'
# General aliases
alias kdel='kubectl delete'
alias kdelf='kubectl delete -f'
# Pod management. # Pod management.
alias kgp='k get pods' alias kgp='kubectl get pods'
alias klp='k logs pods' alias kgpw='kgp --watch'
alias kep='k edit pods' alias kgpwide='kgp -o wide'
alias kdp='k describe pods' alias kep='kubectl edit pods'
alias kdelp='k delete pods' alias kdp='kubectl describe pods'
alias kdelp='kubectl delete pods'
alias kgpall='k get pods --all-namespaces -o wide' alias kgpall='k get pods --all-namespaces -o wide'
# get pod by label: kgpl "app=myapp" -n myns
alias kgpl='kgp -l'
# Service management. # Service management.
alias kgs='k get svc' alias kgs='kubectl get svc'
alias kes='k edit svc' alias kgsw='kgs --watch'
alias kds='k describe svc' alias kgswide='kgs -o wide'
alias kdels='k delete svc' 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'
# ConfigMap management
alias kgcm='kubectl get configmaps'
alias kecm='kubectl edit configmap'
alias kdcm='kubectl describe configmap'
alias kdelcm='kubectl delete configmap'
# Secret management # Secret management
alias kgsec='k get secret' alias kgsec='kubectl get secret'
alias kdsec='k describe secret' alias kdsec='kubectl describe secret'
alias kdelsec='k delete secret' alias kdelsec='kubectl delete secret'
# Deployment management. # Deployment management.
alias kgd='k get deployment' alias kgd='kubectl get deployment'
alias ked='k edit deployment' alias kgdw='kgd --watch'
alias kdd='k describe deployment' alias kgdwide='kgd -o wide'
alias kdeld='k delete deployment' alias ked='kubectl edit deployment'
alias ksd='k scale deployment' alias kdd='kubectl describe deployment'
alias krsd='k rollout status deployment' alias kdeld='kubectl delete deployment'
alias ksd='kubectl scale deployment'
alias krsd='kubectl rollout status deployment'
# Rollout management. # Rollout management.
alias kgrs='k get rs' alias kgrs='kubectl get rs'
alias krh='k rollout history' alias krh='kubectl rollout history'
alias kru='k rollout undo' 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='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 plugin
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.
**NOTE:** completion might not work for recent Laravel versions since it hasn't been updated since 2012.
In that case, check out plugins `laravel4` and `laravel5`.
To use it, add `laravel` to the plugins array in your zshrc file:
```zsh
plugins=(... laravel)
```
## Aliases
| Alias | Command | Description |
|-----------|--------------------------|----------------------|
| artisan | `php artisan` | Main Artisan command |
| bob | `php artisan bob::build` | Main Bob command |
# 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 |
...@@ -4,8 +4,10 @@ typeset -g ZSH_LAST_WORKING_DIRECTORY ...@@ -4,8 +4,10 @@ typeset -g ZSH_LAST_WORKING_DIRECTORY
# Updates the last directory once directory is changed # Updates the last directory once directory is changed
chpwd_functions+=(chpwd_last_working_dir) chpwd_functions+=(chpwd_last_working_dir)
chpwd_last_working_dir() { chpwd_last_working_dir() {
local cache_file="$ZSH_CACHE_DIR/last-working-dir" if [ "$ZSH_SUBSHELL" = 0 ]; then
pwd >| "$cache_file" local cache_file="$ZSH_CACHE_DIR/last-working-dir"
pwd >| "$cache_file"
fi
} }
# Changes directory to the last working directory # Changes directory to the last working directory
......
#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
# To use: add a .lighthouse file into your directory with the URL to the # To use: add a .lighthouse file into your directory with the URL to the
# individual project. For example: # individual project. For example:
# https://rails.lighthouseapp.com/projects/8994 # https://rails.lighthouseapp.com/projects/8994
# Example usage: http://screencast.com/t/ZDgwNDUwNT # Example usage: https://screencast.com/t/ZDgwNDUwNT
open_lighthouse_ticket () { open_lighthouse_ticket () {
if [ ! -f .lighthouse-url ]; then if [ ! -f .lighthouse-url ]; then
echo "There is no .lighthouse-url file in the current directory..." echo "There is no .lighthouse-url file in the current directory..."
......
# lol
Plugin for adding catspeak aliases, because why not
## Enabling the plugin
1. Open your `.zshrc` file and add `lol` in the plugins section:
```zsh
plugins=(
# all your enabled plugins
lol
)
```
2. Reload the source file or restart your Terminal session:
```console
$ source ~/.zshrc
$
```
## Aliases
| Alias | Command |
| ------------ | ---------------------------------------------------------------- |
| `:3` | `echo` |
| `alwayz` | `tail -f` |
| `bringz` | `git pull` |
| `btw` | `nice` |
| `byes` | `exit` |
| `chicken` | `git add` |
| `cya` | `reboot` |
| `donotwant` | `rm` |
| `dowant` | `cp` |
| `gimmeh` | `touch` |
| `gtfo` | `mv` |
| `hackzor` | `git init` |
| `hai` | `cd` |
| `icanhas` | `mkdir` |
| `ihasbucket` | `df -h` |
| `iminurbase` | `finger` |
| `inur` | `locate` |
| `invisible` | `cat` |
| `iz` | `ls` |
| `kthxbai` | `halt` |
| `letcat` | `git checkout` |
| `moar` | `more` |
| `nomnom` | `killall` |
| `nomz` | `ps aux` |
| `nowai` | `chmod` |
| `oanward` | `git commit -m` |
| `obtw` | `nohup` |
| `onoz` | `cat /var/log/errors.log` |
| `ooanward` | `git commit -am` |
| `plz` | `pwd` |
| `pwned` | `ssh` |
| `rtfm` | `man` |
| `rulz` | `git push` |
| `tldr` | `less` |
| `violenz` | `git rebase` |
| `visible` | `echo` |
| `wtf` | `dmesg` |
| `yolo` | `git commit -m "$(curl -s https://whatthecommit.com/index.txt)"` |
## Usage Examples
```sh
# mkdir new-directory
icanhas new-directory
# killall firefox
nomnom firefox
# chmod u=r,go= some.file
nowai u=r,go= some.file
# ssh root@catserver.org
pwned root@catserver.org
# git commit -m "$(curl -s https://whatthecommit.com/index.txt)"
yolo
```
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