Skip to content

Commit

Permalink
add kubectl-pv
Browse files Browse the repository at this point in the history
  • Loading branch information
killwing committed Sep 8, 2019
1 parent 6903d93 commit d889055
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
3 changes: 3 additions & 0 deletions install_tools_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ curl -OL https://raw.githubusercontent.com/jonmosco/kube-ps1/master/kube-ps1.sh
git clone --depth 1 https://github.com/junegunn/fzf.git .fzf && .fzf/install --bin
ln -sfv .fzf/bin/fzf ./fzf

# bat
curl -L -o bat.deb https://github.com/sharkdp/bat/releases/download/v0.12.1/bat_0.12.1_amd64.deb && dpkg -i bat.deb && rm bat.deb

cd -
5 changes: 0 additions & 5 deletions scripts/buildTags

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/git-icdiff

This file was deleted.

41 changes: 41 additions & 0 deletions scripts/kubectl-pv
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
set -euo pipefail

PARSED=$(getopt -o hn: -l help,namespace: -n "$0" -- "$@")
[ $? -ne 0 ] && exit 1
eval set -- "$PARSED"

ns=""
while true; do
case "$1" in
-h|--help)
echo "kubectl pv [-n <namespace>] <resource-kind>"
exit 0
;;
-n|--namespace)
ns="$2"
shift 2
;;
--)
shift
break
;;
*)
echo "unexpect error"
exit 1
;;
esac
done

if [[ $# -ne 1 ]]; then
echo "$0: resource kind is required."
exit 1
fi

kind="$1"

if [ -n "$ns" ]; then
ns="-n"$ns
fi

kubectl get $kind $ns -oname | fzf --preview "kubectl -oyaml $ns get {}|bat -n -l yaml --color=always" --bind ctrl-n:preview-page-down,ctrl-p:preview-page-up --preview-window=right:60%

0 comments on commit d889055

Please sign in to comment.