Skip to content

Instantly share code, notes, and snippets.

@pida42
Created September 2, 2021 13:25
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 pida42/edbd853c2513c8787deaa3d61430ec51 to your computer and use it in GitHub Desktop.
Save pida42/edbd853c2513c8787deaa3d61430ec51 to your computer and use it in GitHub Desktop.
Bash (.bashrc, .profile, ...) custom functions
# [...]
# Docker functions
function docker-exec() {
Container=$1
echo "Running command: docker exec -ti $Container /bin/bash"
docker exec -ti $Container /bin/bash
}
function docker-exec-sh() {
Container=$1
echo "Running command: docker exec -ti $Container /bin/sh"
docker exec -ti $Container /bin/sh
}
# Kubernetes
function k8exec () {
kubectl exec -ti $1 -- /bin/bash
}
function k8exec-sh () {
kubectl exec -ti $1 -- /bin/sh
}
# require configured hosts /etc/hosts or dns to resolve nodes
# require also configured ssh login using certificate or any other method to be able to connect via ssh without any confirmation or second auth-factors and so on
function k8clear () {
echo -e
echo -e ":: Running Docker data prune on:"
echo -e " - node1.k8s"
echo -e " - node2.k8s"
echo -e " - node3.k8s"
echo -e
ssh node1.k8s "docker system prune --all --volumes --force"
ssh node2.k8s "docker system prune --all --volumes --force"
ssh node3.k8s "docker system prune --all --volumes --force"
# [...]
echo -e
}
# Other
function psaux() {
str="$1"; shift
ps aux | grep ${str}
}
# du -h -x --max-depth=1 <path>
function duh() {
dir="$1"; shift
du -h -x --max-depth=1 "${dir}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment