tianyunperfect 3 年之前
父節點
當前提交
f80a753d76
共有 2 個文件被更改,包括 81 次插入0 次删除
  1. 73 0
      sh-demo/rc/baserc.sh
  2. 8 0
      sh-demo/sh-demo.iml

+ 73 - 0
sh-demo/rc/baserc.sh

@@ -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"
+}

+ 8 - 0
sh-demo/sh-demo.iml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>