Skip to content

Commit

Permalink
zsh with auto-completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Zaniewski committed Jan 27, 2020
1 parent 0268933 commit b0cd12a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ Quick testing of a cluster with well-known/customized `kubectl` setup.

There are two images, one for bash shell and one for zsh.

- ``kubectl`` v 1.17.2
- ``kubectl`` bash/zsh completion
- ``k9s`` cluster monitoring tool
- common .bashrc/.zshrc aliases
- `kubectl` v 1.17.2, bash/zsh completion
- `zsh-autosuggestions` for zsh shell
- `kubectl`
- `k9s` cluster monitoring tool
- popular tools: `curl, wget, git`
- useful .bashrc/.zshrc aliases

## How to use

Expand All @@ -28,9 +30,13 @@ After running docker container, all the clusters running on the localhost should

## How the images are build

docker build --rm -f "Dockerfile" -t piotrzan/kubectl-comp "." - __this builds image with bash shell__
### Build image with bash shell

docker build --rm -f "Dockerfile" -t piotrzan/kubectl-comp:zsh "." - __this builds image with zsh shell__
docker build --rm -f "Dockerfile" -t piotrzan/kubectl-comp "."

### Build image with zsh shell

docker build --rm -f "Dockerfile" -t piotrzan/kubectl-comp:zsh "."

## Convinient scripts to run the contianer

Expand All @@ -51,4 +57,4 @@ docker cp ./config kubectl-host:./root/.kube`

## Extending the image

If you would like to add your own customization or ``krew`` plugins, you can easily do it and use `docker commit` to create your own version of the image.
If you would like to add your own customization, you can easily do it and use `docker commit` to create your own version of the image.
20 changes: 7 additions & 13 deletions zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

# Path to your oh-my-zsh installation.
export ZSH="/root/.oh-my-zsh"
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

# source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

if [ $commands[kubectl] ]; then source <(kubectl completion zsh); fi
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
Expand Down Expand Up @@ -100,26 +102,18 @@ source $ZSH/oh-my-zsh.sh
# alias ohmyzsh="mate ~/.oh-my-zsh"
# # My path aliases
alias kdump='kubectl get all --all-namespaces'
alias addkey='eval $(ssh-agent) && ssh-add'
alias krun='k run -h | grep "# " -A2'
alias kdiag='kubectl run -it --rm debug --image=busybox --restart=Never -- sh'
alias diskusage='du -sh * | sort -h --reverse'
alias ll='ls -lah'

eval $(dircolors -p | sed -e 's/DIR 01;34/DIR 01;36/' | dircolors /dev/stdin)
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"

# add Pulumi to the PATH
export PATH=$PATH:$HOME/.krew/bin
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
export PATH=$PATH:"$ZSH_CUSTOM/plugins/navi"

export KUBECONFIG=$HOME/.kube/config





PATH=$HOME/.local/bin:$PATH

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
kcdebug() { kubectl run -i --rm --tty debug --image=busybox --restart=Never -- sh }
alias diskusage='du -sh * | sort -h --reverse'


11 changes: 7 additions & 4 deletions zsh/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/bin/bash
echo 'Bootstrap steps start here:'

echo '[STEP 1] Creating directory for kubectl config'
mkdir /root/.kube

echo '[STEP 2] Installing k9s awesomeness'
(
set -x &&
wget -c https://github.com/derailed/k9s/releases/download/v0.13.4/k9s_0.13.4_Linux_x86_64.tar.gz -O - | tar -xz &&
chmod +x k9s &&
mv k9s /usr/local/bin/
)

echo 'Installing Oh-My-Zsh'
echo '[STEP 3] Installing Oh-My-Zsh'
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended

echo 'Installing zsh-autosuggestions'
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
echo '[STEP 4] Installing zsh-autosuggestions plugin'
git clone https://github.com/zsh-users/zsh-autosuggestions /root/.oh-my-zsh/custom/plugins/zsh-autosuggestions

# Add krew to path to call it from kubectl
echo '[STEP 5] Setting zsh as default shell'
chsh -s $(which zsh)

0 comments on commit b0cd12a

Please sign in to comment.