sh 个人Bashrc个人资料 - 别名
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 个人Bashrc个人资料 - 别名相关的知识,希望对你有一定的参考价值。
cp ~/.zshrc ~/.zshrc-backup.`date +%F-%H%M`
cat << EOF >> ~/.zshrc
# @ ~/.bash_profile | ~/.bashrc | ~/.zshrc
alias youtube-dl-mp3='youtube-dl -x --audio-format mp3 --audio-quality 1'
## docker management
alias my_dock_kill_rm='docker kill $(docker ps -aq) ; docker rm $(docker ps -aq)'
alias my_dock_rmi_all='docker rmi -f $(docker images -aq)'
my_dock_teardown() { docker kill $(docker ps -aq) ; docker rm $(docker ps -aq) ; docker rmi -f $(docker images -aq) ; docker volume prune -f ; docker network prune -f ; }
my_dock_in() { docker exec -it $1 sh ; }
alias dcu="docker-compose up -d"
alias dcd="docker-compose down"
alias di="docker images"
drmi() { docker rmi $1 ; }
## docker containers
alias my_get_me_centos='docker run -it --privileged=true -v $(pwd):/shared centos:7 bash'
alias my_get_me_fedora='docker run -it --privileged=true -v $(pwd):/shared fedora:27 bash'
alias my_get_me_ubuntu16='docker run -it --privileged=true -v $(pwd):/shared ubuntu:16.04 bash'
alias my_get_me_alpine='docker run -it --privileged=true -v $(pwd):/shared alpine:3.6 sh'
alias my_get_me_debian='docker run -it --privileged=true -v $(pwd):/shared debian:9.2 sh'
my_get_me_run() { docker run -it -v $(pwd):/shared $1 $2 ; }
## kubernetes
kube_controllers(){
kubectl $1 get deploy,rs,ds,sts,cj,jobs,rc ;
}
kube_accounts(){
kubectl $1 get clusterrolebindings,clusterroles,sa ;
}
helm_create() {
kubectl -n kube-system create serviceaccount tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account=tiller
}
helm_delete() {
kubectl -n kube-system delete deployment tiller-deploy
kubectl delete clusterrolebinding tiller
kubectl -n kube-system delete serviceaccount tiller
}
## ansible
my_encrypt_vault() { ansible-vault encrypt --vault-password-file=~/keys/ansible_vault.key --output=vault_$1 vars_$1 ; }
my_decrypt_vault() { ansible-vault decrypt --vault-password-file=~/keys/ansible_vault.key --output=vars_$1 vault_$1 ; }
my_ansible_facts() { ansible all -i "$1" -m setup ; }
alias ansible-playbook-3.6='ansible-playbook -e ansible_python_interpreter=/usr/bin/python3.6'
## git
my_git_changelog() { git log --oneline --no-merges $1 ; }
my_git_clone() { git clone --recursive $1 ;}
alias my_git_push='git push --recurse-submodules=on-demand'
alias my_git_submodule_update='git submodule update --remote --merge --recursive'
my_git_init(){ git init ; git config --local user.name "Carles San Agustin" ; git config --local user.email $1 ; git config --local http.sslVerify "false" ; touch README.md .gitignore ; }
## ssh
my_tunnel() { ssh -N -L $1\:localhost:$2 $3 ; }
# my_tunnel 8161 8161 user@example.com
my_tunnelr() { ssh -N -R $1\:localhost:$2 $3 ; }
# my_tunnelr 19999 22 user@example.com
alias sshp="ssh -o StrictHostKeyChecking=no -o PreferredAuthentications=password -o PubkeyAuthentication=no -o ServerAliveInterval=60 "
alias sshk="ssh -o StrictHostKeyChecking=no -o PreferredAuthentications=publickey -o PubkeyAuthentication=yes -o ServerAliveInterval=60 "
## system
my_folder_size() { du -hsx $1 | sort -rh | head -10; }
my_chown() { sudo chown -Rf $USER:$USER $1 ; }
alias my_duf='du -sk * | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit} - ${fname}"; break; fi; size=$((size/1024)); done; done'
#alias my_duf='du -skh * | sort -n | tac'
alias my_duf_hidden='du -ahd1 | sort -h'
alias my_permits="sudo find * -type d -print0 | sudo xargs -0 chmod 0755 && sudo find . -type f -print0 | sudo xargs -0 chmod 0644"
my_process_count() { ps -ef | awk '{ print $8 }' | sort -n | uniq -c | sort -n ; }
alias my_process_total='ps -A --no-headers | wc -l'
alias my_process_usage='ps aux --sort=%mem,%cpu'
my_kill_processes() { ps -ef | grep $1 | grep -v grep | awk '{print $2}' | xargs kill -9 ; }
alias my_netstat="netstat -tulpn"
alias my_netstat_a="netstat -tulpna"
my_curl() { curl -s -D - $1 -o /dev/null ; }
svc_logs() { sudo journalctl -f -u $1 ; }
my_newline() { awk '{gsub(/\\n/,"\n")}1' $1 }
alias sed_newline="sed -i 's/\\n/\n/g' "
# from: https://goo.gl/EeGNSf
my_topcommands() { fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10 }
# only personal fedora workstation
my_clear_workstation(){
sudo rm -Rf /var/crash/* ; \
sudo rm -Rf /var/cache/PackageKit/28/metadata/updates/packages/* ; \
sudo rm -Rf /var/cache/PackageKit/28/metadata/skype-stable/packages/* ; \
sudo rm -Rf /var/cache/PackageKit/28/metadata/docker-ce-stable/packages/* ; \
sudo pkcon refresh force -c -1 ;
}
EOF
以上是关于sh 个人Bashrc个人资料 - 别名的主要内容,如果未能解决你的问题,请参考以下文章