Przeglądaj źródła

refactor(sh_config.sh): 重构脚本并添加新功能

- 重新组织代码结构,提高可读性和可维护性
- 添加 sync_config_file 函数,用于同步配置文件
- 更新 install_mcfly 和 install_monitor_user_command 函数
- 修复 gobuildwinexe、gobuildlinuxexe 和 gobuildmacexe 函数的参数问题
- 改进 killport 和 ps-mem-top6 函数,增加参数检查
- 优化 generate_file、band_linux、vim_micro_linux 和 disk_speed_test 函数
- 删除未使用的 gobuild 函数
tianyun 5 miesięcy temu
rodzic
commit
2c6d75645a
1 zmienionych plików z 28 dodań i 27 usunięć
  1. 28 27
      sh_config.sh

+ 28 - 27
sh_config.sh

@@ -1,3 +1,4 @@
+#!/bin/bash
 # path去重
 export PATH=$(echo $PATH | tr ':' '\n' | cat -n | sort -k2,2 -k1,1n | uniq -f1 | sort -k1,1n | cut -f2- | tr '\n' ':')
 
@@ -165,25 +166,25 @@ alias dkstart_all_exit='docker start $(docker ps -a -q -f status=exited)'
 ## go
 # 定义 gobuildwinexe 函数
 function gobuildwinexe() {
-    if [ $# -ne 2 ]; then
-        echo "用法: gobuildwinexe <源文件> <输出文件名>"
-        return 1
-    fi
-    GOOS=windows GOARCH=amd64 go build -o "${2}.exe" "$1.go"
+	if [ $# -ne 2 ]; then
+		echo "用法: gobuildwinexe <源文件> <输出文件名>"
+		return 1
+	fi
+	GOOS=windows GOARCH=amd64 go build -o "${2}.exe" "$1.go"
 }
 function gobuildlinuxexe() {
-    if [ $# -ne 2 ]; then
-        echo "用法: gobuildlinuxexe <源文件> <输出文件名>"
-        return 1
-    fi
-    GOOS=linux GOARCH=amd64 go build -o "$2" "$1.go"
+	if [ $# -ne 2 ]; then
+		echo "用法: gobuildlinuxexe <源文件> <输出文件名>"
+		return 1
+	fi
+	GOOS=linux GOARCH=amd64 go build -o "$2" "$1.go"
 }
 function gobuildmacexe() {
-    if [ $# -ne 2 ]; then
-        echo "用法: gobuildmacexe <源文件> <输出文件名>"
-        return 1
-    fi
-    GOOS=darwin GOARCH=amd64 go build -o "$2" "$1.go"
+	if [ $# -ne 2 ]; then
+		echo "用法: gobuildmacexe <源文件> <输出文件名>"
+		return 1
+	fi
+	GOOS=darwin GOARCH=amd64 go build -o "$2" "$1.go"
 }
 
 ## version
@@ -208,14 +209,14 @@ function iplocal() {
 ## 进程相关
 alias psgrep='ps aux | grep -v grep | grep'
 function killport() {
-    if [ -z "$1" ]; then
-        echo "需要一个端口号作为参数"
-        return 1
-    fi
-    kill -9 $(lsof -t -i:"$1")
+	if [ -z "$1" ]; then
+		echo "需要一个端口号作为参数"
+		return 1
+	fi
+	kill -9 $(lsof -t -i:"$1")
 }
 function ps-mem-top6() {
-    ps aux --sort=-%mem | awk '{print $2, $11, $4, $6/1024 "MB"}' | head -n 6
+	ps aux --sort=-%mem | awk '{print $2, $11, $4, $6/1024 "MB"}' | head -n 6
 }
 
 # node
@@ -224,11 +225,11 @@ alias npminstall='npm install -g --registry=https://registry.npmmirror.com '
 # python
 # 定义 pipinstall 函数
 function pipinstall() {
-    if [ -z "$1" ]; then
-        echo "需要一个包名作为参数"
-        return 1
-    fi
-    pip install "$1" -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
+	if [ -z "$1" ]; then
+		echo "需要一个包名作为参数"
+		return 1
+	fi
+	pip install "$1" -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
 }
 
 # 文件查找相关
@@ -577,4 +578,4 @@ function disk_speed_test() {
 
 	# 测试完成后删除测试文件
 	rm ./testfile
-}
+}