|
@@ -0,0 +1,73 @@
|
|
|
+# ====== 添加PATH并自动去重
|
|
|
+function addToPATH() {
|
|
|
+ case ":$PATH:" in
|
|
|
+ *":$1:"*) : ;; # already there
|
|
|
+ *) PATH="$1:$PATH" ;; # or PATH="$PATH:$1"
|
|
|
+ esac
|
|
|
+}
|
|
|
+
|
|
|
+# ====== docker
|
|
|
+dockerin() {
|
|
|
+ docker exec -it $1 /bin/bash
|
|
|
+}
|
|
|
+alias dockerps='docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}"'
|
|
|
+alias dockerpsa='docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}"'
|
|
|
+
|
|
|
+# ====== git
|
|
|
+alias g='git'
|
|
|
+alias ga='git add'
|
|
|
+alias gc='git checkout'
|
|
|
+alias gm='git commit -m'
|
|
|
+alias gb='git branch'
|
|
|
+alias gs='git status'
|
|
|
+
|
|
|
+# ====== zshrc
|
|
|
+alias rc-vim='vim ~/.zshrc'
|
|
|
+alias rc-reload='source ~/.zshrc'
|
|
|
+
|
|
|
+# ====== 排序-默认 10
|
|
|
+duhead() {
|
|
|
+ du -sh * | sort -hr | head -n ${1:-10}
|
|
|
+}
|
|
|
+
|
|
|
+# ====== 进程查询与关闭
|
|
|
+# 自动过滤grep
|
|
|
+function tgrep() {
|
|
|
+ ps aux | grep $1 | grep -v grep
|
|
|
+}
|
|
|
+function tkillp() {
|
|
|
+ local pid
|
|
|
+ pid=$(ps ax | grep $1 | grep -v grep | awk '{ print $1 }')
|
|
|
+ kill -9 $pid
|
|
|
+ echo -n "Killed $1 (process $pid)"
|
|
|
+}
|
|
|
+# 关闭端口管理的程序
|
|
|
+function tkillport() {
|
|
|
+ kill -9 $(lsof -t -i:$1)
|
|
|
+}
|
|
|
+
|
|
|
+# ====== IP查询
|
|
|
+function iplocal() {
|
|
|
+ ifconfig | rg inet | rg -v '127.0.0.1' | rg -v 'inet6' | awk '{print $2}'
|
|
|
+}
|
|
|
+function ipremote() {
|
|
|
+ curl cip.cc
|
|
|
+}
|
|
|
+
|
|
|
+# ====== 删除大文件
|
|
|
+function rmbigdir() {
|
|
|
+ mkdir -p /tmp/blank
|
|
|
+ rsync --delete-before -d /tmp/blank $1
|
|
|
+}
|
|
|
+function rmbigfile() {
|
|
|
+ touch /tmp/blankfile
|
|
|
+ rsync --delete-before -d --progess --stats /tmp/blankfile $1
|
|
|
+}
|
|
|
+
|
|
|
+# ====== tart untart
|
|
|
+alias tart='tar -zcvf'
|
|
|
+alias untart='tar -zxvf'
|
|
|
+
|
|
|
+sedfile() {
|
|
|
+ sed -i "s/$2/$3/g" "$1"
|
|
|
+}
|