Last active
April 18, 2026 07:01
-
-
Save NewbMiao/533c03ca18fb7ffa34d9a2e24ea076e3 to your computer and use it in GitHub Desktop.
some cmd for daily used
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
| plugins=( | |
| git | |
| kubectl | |
| kubectx | |
| ) | |
| KUBE_PS1_SYMBOL_DEFAULT="※" | |
| . ~/.oh-my-zsh/plugins/kube-ps1/kube-ps1.plugin.zsh | |
| PROMPT='$(kube_ps1)'$PROMPT | |
| #homebrew | |
| export HOMEBREW_NO_AUTO_UPDATE=1 | |
| export PATH=/opt/homebrew/opt/make/libexec/gnubin:"${KREW_ROOT:-$HOME/.krew}/bin:$HOME/bin:$PATH" | |
| #app | |
| alias allowAllDmg="sudo spctl --global-disable" | |
| alias flushDNS="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; say DNS cache flushed;" | |
| #git | |
| function gshowbig5(){ | |
| git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print $1}')" | |
| } | |
| function gRmBigFile(){ | |
| if [ ! -n "$1" ]; then | |
| echo "pls enter the filename!" | |
| return 1 | |
| fi | |
| echo "start to del $1" | |
| git filter-repo --path "$1" --invert-paths --force | |
| echo "done (filter-repo handles gc automatically)" | |
| } | |
| #docker | |
| alias drminone="docker image prune -f" | |
| alias drmall='docker rm -f $(docker ps -a -q)' | |
| alias drmexited="docker container prune -f" | |
| alias dshowip="docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \$(docker ps -aq)" | |
| alias di="docker images" | |
| alias dexec=dexec | |
| function dexec(){ | |
| id=$1 | |
| if [ ${#1} != 12 ];then | |
| id=$(docker images|grep $1) | |
| echo "find images, use first one:\n"$id | |
| id=$(docker images|grep $1|head -n 1|awk '{print $3}') | |
| else | |
| echo "exec bash to: "$(docker images|grep $id) | |
| fi | |
| docker run -it $id /bin/bash | |
| } | |
| function commitUpdate() { | |
| OLD_EMAIL=$1 | |
| if [ "$OLD_EMAIL" = "" ]; then | |
| echo "Need provide old email" | |
| return 1 | |
| fi | |
| git filter-repo --mailmap /dev/stdin <<EOF | |
| <newbvirgil@gmail.com> newbmiao <$OLD_EMAIL> | |
| EOF | |
| } | |
| alias gitMe='git config user.name newbmiao && git config user.email newbvirgil@gmail.com' | |
| # kubectl | |
| function knodepoolpods(){ | |
| nodepool=$1 | |
| kubectl get pods --all-namespaces -o wide --sort-by='.metadata.creationTimestamp' | grep -E "$(kubectl get nodes -l alibabacloud.com/nodepool-id=$nodepool -o jsonpath='{.items[*].metadata.name}' | tr ' ' '|')" | |
| } | |
| function kroot(){ | |
| kubectl run r00t --restart=Never -ti --rm --image lol --overrides \ | |
| '{"spec":{"hostPID":true,"containers":[{"name":"1","image":"alpine","command":["nsenter","--mount=/proc/1/ns/mnt","--","/bin/sh"],"stdin":true,"tty":true,"securityContext":{"privileged":true}}]}}' | |
| } | |
| function kdebug(){ | |
| echo "Debugging container via cmd:" | |
| container=$(kubectl get pod "$1" -o jsonpath='{.spec.containers[*].name}') | |
| echo kubectl debug -it "$1" --image=registry.cn-hangzhou.aliyuncs.com/acs/curl --target="$container" | |
| } | |
| function kdebugnode(){ | |
| echo "Debugging node via cmd:" | |
| echo kubectl debug -it "node/$1" --image=registry.cn-hangzhou.aliyuncs.com/acs/busybox | |
| } | |
| alias k=kubectl | |
| # autoload -U +X bashcompinit && bashcompinit | |
| complete -F __start_kubectl k | |
| alias kbp="kubectl run busybox --rm -it --image=busybox --restart=Never --command -- /bin/sh" | |
| alias kap="kubectl run alpine --rm -it --image=alpine --restart=Never --command -- /bin/sh" | |
| alias clean_terraform="find ~/folder_placeholder -type d -name \".terraform\" -exec rm -rf {} +" | |
| alias run_infra_tfe='docker run --name tfe_container -it -v $PWD:/workspace -w /workspace infra_tfe bash' | |
| alias backup_infra_tfe="docker commit tfe_container infra_tfe" | |
| alias myip="curl ifconfig.me" | |
| alias colima_start="colima start --kubernetes" | |
| alias opstool="~/workdir/DevOpsTool/opstool" | |
| alias memocard="cd ~/Documents/tech/obsidian-notes/.memocard && npm start" | |
| [[ "$TERM_PROGRAM" == "kiro" ]] && . "$(kiro --locate-shell-integration-path zsh)" | |
| export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment