Last active
March 20, 2023 13:39
-
-
Save NewbMiao/533c03ca18fb7ffa34d9a2e24ea076e3 to your computer and use it in GitHub Desktop.
some cmd for daily used
This file contains 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
#homebrew | |
export HOMEBREW_NO_AUTO_UPDATE=1 && export HOMEBREW_AUTO_UPDATING=0 | |
#app | |
alias allowAllDmg="sudo spctl --master-disable" | |
function dnsrestart(){ | |
sudo launchctl stop homebrew.mxcl.dnsmasq | |
sudo launchctl start homebrew.mxcl.dnsmasq | |
sudo killall -HUP mDNSResponder | |
} | |
alias flushDNS="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; say DNS cache flushed;" | |
#git | |
alias gmts="git config --global commit.template /Users/lei.miao/gitmessage/.gitmessage_emily" | |
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!" | |
else | |
echo "start to del "$1 | |
fi | |
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch '$1 --prune-empty --tag-name-filter cat -- --all | |
echo "start gc" | |
rm -rf .git/refs/original/ | |
git reflog expire --expire=now --all | |
git gc --prune=now | |
} | |
#docker | |
alias drminone="docker images |grep none|awk '{print \$3}'|xargs docker rmi -f" | |
alias drmall='docker rm -f $(docker ps -a -q)' | |
alias drmexited="docker ps -a|grep Exited|awk '{print \$1}' |xargs docker rm -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 | |
} | |
alias commitUpdate=commitUpdate | |
function commitUpdate() { | |
OLD_EMAIL=$1 | |
if [ "$OLD_EMAIL" = "" ]; then | |
echo "Need provide old email" | |
exit | |
fi | |
git filter-branch --env-filter ' | |
OLD_EMAIL='$OLD_EMAIL' | |
CORRECT_EMAIL="[email protected]" | |
CORRECT_NAME="newbmiao" | |
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]; then | |
export GIT_COMMITTER_NAME="$CORRECT_NAME" | |
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" | |
fi | |
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]; then | |
export GIT_AUTHOR_NAME="$CORRECT_NAME" | |
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" | |
fi | |
' --tag-name-filter cat -- --branches --tags | |
} | |
alias gitMe='git config user.name newbmiao && git config user.email [email protected]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment