Skip to content

Instantly share code, notes, and snippets.

@mcascone
Last active February 23, 2023 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcascone/4861119dd4fcc3a0199d388ccca09367 to your computer and use it in GitHub Desktop.
Save mcascone/4861119dd4fcc3a0199d388ccca09367 to your computer and use it in GitHub Desktop.
my zsh aliases
#!/bin/zsh
# spell:disable
# this file is sourced by ~/.zshrc every time a new shell is opened
# pull in keys/tokens/etc
source ~/.secrets
## MISC
alias ll='ls -algp'
alias py="python3"
alias g="grep"
alias tree="tree -alF -I .git --filesfirst"
# hey, i'm on a mac!
alias finder="open -a finder"
## Starship prompt
alias st=starship
alias stt='st toggle'
alias sttg='stt gcloud'
alias sttk='stt kubernetes'
### GCLOUD
alias gc=gcloud
alias gci="gc init"
alias gccl='gc container clusters list'
alias gcc='gc container'
alias show-creds='
echo "Using $CREDS_NAME AWS credentials"
echo "AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION"
echo "AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID"
echo "AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY"
echo "GCP_PROJECT_ID: $GCP_PROJECT_ID"
echo "GOOGLE_CREDENTIALS_PATH: $GOOGLE_CREDENTIALS_PATH"
'
# -A Include directory entries whose names begin with a dot (‘.’) except for . and ..
# -h When used with the -l option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte,
# Terabyte and Petabyte in order to reduce the number of digits to four or fewer using base 2 for sizes.
# -o List in long format, but omit the group id.
# -p Write a slash (‘/’) after each filename if that file is a directory.
alias la='ls -A -hop'
alias ls='ls -Gp'
alias rmd='rm -rf'
alias code='open -a "visual studio code"'
alias edp='code ~/.zshrc ~/.alias'
alias cl='clear'
alias relp="source ~/.zshrc"
alias gh='cd ~/Bitovi/github'
alias bgh=gh
alias ygh='cd ~/yum/github'
alias mgh='cd ~/github'
alias gbh="cd $BITOVI_HOME"
## fat-finger corrections
alias owd=pwd
alias ks=ls
alias sl=ls
## GIT
alias open_remote="git remote -v | grep -m 1 origin | sed -e 's/origin//' -e 's/(fetch)//' -e 's/\.git//' | xargs open"
alias or=open_remote
alias gr='git remote -v'
alias com='git checkout main || git checkout master'
alias cod='git checkout develop'
## TERRAFORM
alias tf=terraform
alias tfa='tf apply -auto-approve'
alias tfp='tf plan'
alias tfd='tf destroy -auto-approve'
alias tfo='tf output'
alias tfs='tf state pull'
alias tfi='tf init'
alias tfv='tf validate'
alias tff='tf fmt'
## BREW
alias b=brew
alias boutdated='b outdated'
alias bout=boutdated
alias bup='b upgrade'
alias binst='b install'
alias bins=binst
alias binstall=binst
alias buninst='b uninstall'
alias bun=buninst
alias blist='b list'
alias bl=blist
##### K8s
## get cluster .kubeconfig info (server, certs, etc)
## add --context=<context-name> to use a specific context
alias k=kubectl
alias kc='kubectl config'
alias kgetcontextdata='kubectl config view --minify --flatten'
alias kgetkubeconfig=kgetcontextdata
alias ksetns='kubectl config set-context --current --namespace'
alias kgetns='kubectl config view --minify | grep namespace'
alias kcgc='kubectl config get-contexts'
alias kcuc='kc use-context'
alias kgpoa='k get po -A'
alias kaf='kubectl apply -f'
alias kdf='kubectl delete -f'
# So that you can use `kubectl run pod-name -n namespace $do > pod.yaml` or with `kubectl create` commands.
export do="-o yaml --dry-run=client"
# run 'k9s $ro' for safety
export ro=--readonly
alias mk=minikube
alias mks='mk status'
alias eks=eksctl
alias ek=eksctl
alias sk=skaffold
alias openlens='open -a openlens'
### DOCKER
# required for images built on mac M1 to work externally
# frequently need to *unset* for remote images to work correctly
alias set-docker-platform='DOCKER_DEFAULT_PLATFORM=linux/amd64'
alias sdp=set-docker-platform
alias unset-docker-platform='unset DOCKER_DEFAULT_PLATFORM'
alias udp=unset-docker-platform
# to use as $ca in docker commands
export ca='--container-architecture=linux/amd64'
alias d=docker
alias dc='docker compose'
alias dls='docker images'
alias dps='docker ps'
alias dpsa='docker ps -a'
alias drm='docker image rm'
alias dr='docker run --rm -it'
alias db='docker build .'
alias dbt='docker build . -t'
##### HELM
alias h=helm
alias hl='helm list'
alias hla='helm list -A'
alias hinst='helm upgrade --install'
alias hinstall=hinst
alias tg=terragrunt
### functions
### pseudo-environments
function prep_bitovi() {
export CREDS_NAME=Bitovi
echo "Setting $CREDS_NAME credentials and env vars."
export AWS_DEFAULT_REGION=ca-central-1
export AWS_ACCESS_KEY_ID=$BITOVI_AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$BITOVI_AWS_SECRET_ACCESS_KEY
}
alias prep_bitovi=prep_bitovi
## YUM
function prep_yum() {
export CREDS_NAME=Yum
echo "Setting $CREDS_NAME credentials and env vars."
export AWS_DEFAULT_REGION=us-east-1
export AWS_ACCESS_KEY_ID=$YUM_AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$YUM_AWS_SECRET_ACCESS_KEY
}
alias prep_yum=prep_yum
alias set-yum-staging-kube='export KUBECONFIG=~/yum/configs/<redacted>'
alias syks=set-yum-staging-kube
alias sysk=syks
alias set-yum-devqa-kube='export KUBECONFIG=~/yum/configs/<redacted>'
alias sykq=set-yum-devqa-kube
alias syqk=sykq
alias set-yum-perf-kube='export KUBECONFIG=~/yum/configs/<redacted>'
alias sykp=set-yum-perf-kube
alias sypk=sykp
alias unset-yum-kube='unset KUBECONFIG'
alias uyk=unset-yum-kube
alias gk='echo $KUBECONFIG'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment