Skip to content

Commit

Permalink
feat(zsh): adds img helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpyoung committed Dec 10, 2023
1 parent 8766236 commit 35b1fdd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
53 changes: 53 additions & 0 deletions zsh/.oh-my-zsh/custom/plugins/img/img.plugin.zsh
Original file line number Diff line number Diff line change
@@ -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"
}
5 changes: 4 additions & 1 deletion zsh/.zshrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#!/usr/bin/env zsh
#
#
#

source ~/.exports
source ~/.spaceship

# zhelp|zalias PLUGIN_NAME
plugins=(
aicure
brew
colored-man-pages
command-not-found
docker
docker-compose
git-auto-fetch
gpg
img
ripgrep
vi-mode
zsh-interactive-cd
Expand Down

0 comments on commit 35b1fdd

Please sign in to comment.