diff --git a/zsh/.oh-my-zsh/custom/plugins/img/img.plugin.zsh b/zsh/.oh-my-zsh/custom/plugins/img/img.plugin.zsh new file mode 100755 index 0000000..878c504 --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/img/img.plugin.zsh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +set +euo pipefail + +# authenticate +k8a() { + AWS_PROFILE=ptc-gbl-identity aws sso login + ENVS=("dev" "staging" "prod") + case $(printf "%s\n" "${ENVS[@]}" | fzf) in + dev) + aws eks update-kubeconfig --region=us-east-1 --name=dev-0002 --profile ptc-gbl-ncsadev-admin + ;; + staging) + aws eks update-kubeconfig --region=us-east-1 --name=stg-0002 --profile ptc-gbl-ncsastaging-admin + ;; + prod) + aws eks update-kubeconfig --region=us-east-1 --name=prod-0002 --profile ptc-gbl-ncsaprod-admin + ;; + esac + which kubens || brew install kubectl + kubens "team-athlete" +} + +# choose a pod via fzf +k8p() { + kubectl get pods | fzf --tac | awk '{print $1}' +} + +# choose a container from a pod via fzf +k8c() { + if [[ -z $1 ]]; then + local -r POD=$(k8p) + else + local -r POD=$1 + fi + kubectl get pod "$POD" -o jsonpath="{range .spec['containers','initContainers']}{[*].name}{\"\n\"}{end}" | fzf +} + +k8d() { + k8p | xargs -I _ kubectl describe pods/_ +} + +k8lf() { + POD=$(k8p) + CONTAINER=$(k8c "$POD") + kubectl logs -f -c "$CONTAINER" "$POD" +} + +k8lp() { + POD=$(k8p) + CONTAINER=$(k8c "$POD") + kubectl logs -p -c "$CONTAINER" "$POD" +} diff --git a/zsh/.zshrc b/zsh/.zshrc index 968e080..39c9e9e 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,11 +1,13 @@ #!/usr/bin/env zsh +# +# +# source ~/.exports source ~/.spaceship # zhelp|zalias PLUGIN_NAME plugins=( - aicure brew colored-man-pages command-not-found @@ -13,6 +15,7 @@ plugins=( docker-compose git-auto-fetch gpg + img ripgrep vi-mode zsh-interactive-cd