Created
September 2, 2021 13:25
-
-
Save pida42/edbd853c2513c8787deaa3d61430ec51 to your computer and use it in GitHub Desktop.
Bash (.bashrc, .profile, ...) custom functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [...] | |
# 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