Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recreate zsh plugin #32

Open
wants to merge 13 commits into
base: generate-aliases
Choose a base branch
from
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,22 +211,24 @@ All commands with the same comment will be grouped together in the generated fil
# Installation

To grab a bunch of aliases without customization get the
`aliases` file and source it in your `bashrc` or `zshrc` file.

## Bash Example
`aliases.sh` file and source it in your `bashrc` or `zshrc` file.

```bash
curl https://raw.githubusercontent.com/Dbz/kube-aliases/master/aliases -o ${HOME}/.kube-aliases
echo "source ${HOME}/.kube-aliases" >> .bashrc
curl https://raw.githubusercontent.com/Dbz/kube-aliases/master/aliases.sh -o ${HOME}/.kube-aliases.sh
echo "source ${HOME}/.kube-aliases.sh" >> .bashrc
```

## Zsh Example
## Oh-My-Zsh Example

To install this as a plugin:

```bash
curl https://raw.githubusercontent.com/Dbz/kube-aliases/master/aliases -o ${HOME}/.kube-aliases
echo "source ${HOME}/.kube-aliases" >> .zshrc
git clone https://github.com/Dbz/kube-aliases.git ~/.oh-my-zsh/custom/plugins/kube-aliases
echo "plugins+=(kube-aliases)" >> ~/.zshrc
```

If you set the `ZSH_CUSTOM` environment variable, then you should modify the git clone directory to be `$ZSH_CUSTOM/plugins/kube-aliases`.

## Generate Aliases

Coming soon
Expand Down
501 changes: 0 additions & 501 deletions aliases

This file was deleted.

523 changes: 523 additions & 0 deletions aliases.sh

Large diffs are not rendered by default.

70 changes: 40 additions & 30 deletions aliases.yaml
Original file line number Diff line number Diff line change
@@ -1,72 +1,74 @@
resources:
certificatesigningrequests:
certificatesigningrequest:
short: csr
clusterrolebindings:
clusterrolebinding:
short: crb
clusterroles:
clusterrole:
short: cr
componentstatus:
short: cs
configmaps:
configmap:
short: cm
controllerrevisions:
controllerrevision:
short: crv
cronjobs:
cronjob:
short: cj
daemonsets:
daemonset:
short: ds
deployments:
deployment:
short: d
endpoints:
endpoint:
short: ep
events:
event:
short: ev
horizontalpodautoscalers:
horizontalpodautoscaler:
short: hpas
ingress:
short: i
jobs:
job:
short: j
limitranges:
limitrange:
short: lr
namespaces:
namespace:
short: ns
networkpolicies:
networkpolicie:
short: np
nodes:
node:
short: n
persistentvolume:
short: pv
persistentvolumeclaims:
persistentvolumeclaim:
short: pvc
poddisruptionbudgets:
poddisruptionbudget:
short: pdb
podpreset:
short: pp
pods:
pod:
short: p
podsecuritypolicies:
podsecuritypolicie:
patmessina marked this conversation as resolved.
Show resolved Hide resolved
short: psp
podtemplates:
podtemplate:
short: pt
replicasets:
replicaset:
short: rs
replicationcontrollers:
replicationcontroller:
short: krc
resourcequotas:
resourcequota:
short: rq
rolebindings:
rolebinding:
short: rb
roles:
role:
short: r
secrets:
secret:
short: sc
serviceaccounts:
serviceaccount:
short: sa
services:
service:
short: s
statefulsets:
statefulset:
short: ss
storageclass:
short: scls

cmds:
- short: c
Expand Down Expand Up @@ -114,6 +116,11 @@ additional:
- short: k
cmd: "kubectl"
comment: "CLI aliases."
- short: kg
cmd: "kubectl get"
patmessina marked this conversation as resolved.
Show resolved Hide resolved
- short: kd
cmd: "kubectl describe"
comment: "CLI aliases."
- short: kctx
cmd: "kubectx"
comment: "CLI aliases."
Expand All @@ -126,6 +133,9 @@ additional:
- short: kaf
cmd: "kubectl apply -f"
comment: "Pushing/modifying configs."
- short: kdf
cmd: "kubectl describe -f"
comment: "Pushing/modifying configs."
- short: kgf
cmd: "kubectl get -f"
comment: "Pushing/modifying configs."
Expand Down
3 changes: 2 additions & 1 deletion generate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cmds:
additional:
- short: wkgp
cmd: "watch kubectl get pods"
comment: "Additional pod commands."
```

Which will generate the following file
Expand All @@ -35,7 +36,7 @@ by running

```bash
make
bin/generate-kube-aliases alias.yaml aliases
bin/generate-kube-aliases alias.yaml aliases.sh
```

# Contributing
Expand Down
5 changes: 5 additions & 0 deletions generate/pkg/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ func Generate(filePath, targetPath string) error {
}
defer aliasFile.Close()

_, err = io.WriteString(aliasFile, "#!/bin/bash\n")
if err != nil {
return fmt.Errorf("Warning: could not write shebang: %v", err)
}

var aliasBuilder strings.Builder
var aliasCMDs types.AliasCMDs
for r := range aliases.Resources {
Expand Down
3 changes: 3 additions & 0 deletions kube-aliases.plugin.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SHELL_NAME=$(basename $SHELL)

source ./aliases.sh