add fish config
This commit is contained in:
32
bin/uzp
32
bin/uzp
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env fish
|
|
||||||
for file in $argv
|
|
||||||
if not test -f "$file"
|
|
||||||
echo "错误: $file 不是有效文件"
|
|
||||||
continue
|
|
||||||
end
|
|
||||||
|
|
||||||
# 1. 获取不带后缀的文件名作为备选文件夹名
|
|
||||||
set -l base_name (string replace -r '\.[^.]+$' '' $file)
|
|
||||||
|
|
||||||
# 2. 预检:获取压缩包根路径下的唯一项目数量
|
|
||||||
# 逻辑:列出所有路径 -> 提取第一级目录/文件名 -> 去重 -> 计数
|
|
||||||
set -l root_items (7z l -slt "$file" | grep "^Path = " | string replace -r '^Path = ' '' | string replace -r '/.*$' '' | sort -u)
|
|
||||||
set -l item_count (count $root_items)
|
|
||||||
|
|
||||||
if test $item_count -eq 0
|
|
||||||
echo "跳过: $file 是空的"
|
|
||||||
continue
|
|
||||||
end
|
|
||||||
|
|
||||||
# 3. 智能判断执行
|
|
||||||
if test $item_count -gt 1
|
|
||||||
# 如果根部有多个文件/文件夹,创建同名目录解压
|
|
||||||
echo "📦 检测到多个根项目 ($item_count),解压至目录: $base_name/"
|
|
||||||
mkdir -p "$base_name"
|
|
||||||
7z x -mmt=on "$file" -o"$base_name"
|
|
||||||
else
|
|
||||||
# 如果根部只有一个项目,直接解压到当前目录
|
|
||||||
echo "📄 检测到单个根项目,直接解压..."
|
|
||||||
7z x -mmt=on "$file"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
24
bin/zp
24
bin/zp
@@ -1,24 +0,0 @@
|
|||||||
#!/usr/bin/env fish
|
|
||||||
# 把之前定义的 zp 函数内容贴进来,去掉外层的 function/end
|
|
||||||
set -l arg_count (count $argv)
|
|
||||||
|
|
||||||
# 检查是否有输入参数
|
|
||||||
if test $arg_count -eq 0
|
|
||||||
echo "用法: zp <文件或目录1> [文件或目录2] ..."
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if test $arg_count -eq 1
|
|
||||||
# 逻辑 A:单个参数,保持原样生成同名 zip
|
|
||||||
set -l name (string trim -r -c / $argv[1])
|
|
||||||
set -l target "$name.zip"
|
|
||||||
echo "🚀 正在多线程压缩单项目: $target"
|
|
||||||
7z a -tzip -mmt=on -mx=5 "$target" "$argv[1]"
|
|
||||||
else
|
|
||||||
# 逻辑 B:多个参数,生成 package_20251219_1540.zip
|
|
||||||
set -l timestamp (date "+%Y%m%d_%H%M%S")
|
|
||||||
set -l target "package_$timestamp.zip"
|
|
||||||
echo "🚀 正在将 $arg_count 个项目打包至: $target"
|
|
||||||
# 直接传入 $argv,7z 会自动处理多个路径
|
|
||||||
7z a -tzip -mmt=on -mx=5 "$target" $argv
|
|
||||||
end
|
|
||||||
108
fish/add-on.fish
108
fish/add-on.fish
@@ -1,5 +1,3 @@
|
|||||||
fish_add_path ~/.flinty/bin
|
|
||||||
|
|
||||||
function sudo --description "让 sudo 识别 fish 函数"
|
function sudo --description "让 sudo 识别 fish 函数"
|
||||||
if functions -q $argv[1]
|
if functions -q $argv[1]
|
||||||
set -l cmd_name $argv[1]
|
set -l cmd_name $argv[1]
|
||||||
@@ -89,66 +87,66 @@ if not locale >/dev/null 2>&1
|
|||||||
set -e LC_CTYPE
|
set -e LC_CTYPE
|
||||||
end
|
end
|
||||||
|
|
||||||
# # 多线程压缩为同名 zip,支持传入多项目
|
# 多线程压缩为同名 zip,支持传入多项目
|
||||||
# function zp
|
function zp
|
||||||
# set -l arg_count (count $argv)
|
set -l arg_count (count $argv)
|
||||||
|
|
||||||
# # 检查是否有输入参数
|
# 检查是否有输入参数
|
||||||
# if test $arg_count -eq 0
|
if test $arg_count -eq 0
|
||||||
# echo "用法: zp <文件或目录1> [文件或目录2] ..."
|
echo "用法: zp <文件或目录1> [文件或目录2] ..."
|
||||||
# return 1
|
return 1
|
||||||
# end
|
end
|
||||||
|
|
||||||
# if test $arg_count -eq 1
|
if test $arg_count -eq 1
|
||||||
# # 逻辑 A:单个参数,保持原样生成同名 zip
|
# 逻辑 A:单个参数,保持原样生成同名 zip
|
||||||
# set -l name (string trim -r -c / $argv[1])
|
set -l name (string trim -r -c / $argv[1])
|
||||||
# set -l target "$name.zip"
|
set -l target "$name.zip"
|
||||||
# echo "🚀 正在多线程压缩单项目: $target"
|
echo "🚀 正在多线程压缩单项目: $target"
|
||||||
# 7z a -tzip -mmt=on -mx=5 "$target" "$argv[1]"
|
7z a -tzip -mmt=on -mx=5 "$target" "$argv[1]"
|
||||||
# else
|
else
|
||||||
# # 逻辑 B:多个参数,生成 package_20251219_1540.zip
|
# 逻辑 B:多个参数,生成 package_20251219_1540.zip
|
||||||
# set -l timestamp (date "+%Y%m%d_%H%M%S")
|
set -l timestamp (date "+%Y%m%d_%H%M%S")
|
||||||
# set -l target "package_$timestamp.zip"
|
set -l target "package_$timestamp.zip"
|
||||||
# echo "🚀 正在将 $arg_count 个项目打包至: $target"
|
echo "🚀 正在将 $arg_count 个项目打包至: $target"
|
||||||
# # 直接传入 $argv,7z 会自动处理多个路径
|
# 直接传入 $argv,7z 会自动处理多个路径
|
||||||
# 7z a -tzip -mmt=on -mx=5 "$target" $argv
|
7z a -tzip -mmt=on -mx=5 "$target" $argv
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
|
|
||||||
# # 多线程解压 zip
|
# 多线程解压 zip
|
||||||
# function uzp
|
function uzp
|
||||||
# for file in $argv
|
for file in $argv
|
||||||
# if not test -f "$file"
|
if not test -f "$file"
|
||||||
# echo "错误: $file 不是有效文件"
|
echo "错误: $file 不是有效文件"
|
||||||
# continue
|
continue
|
||||||
# end
|
end
|
||||||
|
|
||||||
# # 1. 获取不带后缀的文件名作为备选文件夹名
|
# 1. 获取不带后缀的文件名作为备选文件夹名
|
||||||
# set -l base_name (string replace -r '\.[^.]+$' '' $file)
|
set -l base_name (string replace -r '\.[^.]+$' '' $file)
|
||||||
|
|
||||||
# # 2. 预检:获取压缩包根路径下的唯一项目数量
|
# 2. 预检:获取压缩包根路径下的唯一项目数量
|
||||||
# # 逻辑:列出所有路径 -> 提取第一级目录/文件名 -> 去重 -> 计数
|
# 逻辑:列出所有路径 -> 提取第一级目录/文件名 -> 去重 -> 计数
|
||||||
# set -l root_items (7z l -slt "$file" | grep "^Path = " | string replace -r '^Path = ' '' | string replace -r '/.*$' '' | sort -u)
|
set -l root_items (7z l -slt "$file" | grep "^Path = " | string replace -r '^Path = ' '' | string replace -r '/.*$' '' | sort -u)
|
||||||
# set -l item_count (count $root_items)
|
set -l item_count (count $root_items)
|
||||||
|
|
||||||
# if test $item_count -eq 0
|
if test $item_count -eq 0
|
||||||
# echo "跳过: $file 是空的"
|
echo "跳过: $file 是空的"
|
||||||
# continue
|
continue
|
||||||
# end
|
end
|
||||||
|
|
||||||
# # 3. 智能判断执行
|
# 3. 智能判断执行
|
||||||
# if test $item_count -gt 1
|
if test $item_count -gt 1
|
||||||
# # 如果根部有多个文件/文件夹,创建同名目录解压
|
# 如果根部有多个文件/文件夹,创建同名目录解压
|
||||||
# echo "📦 检测到多个根项目 ($item_count),解压至目录: $base_name/"
|
echo "📦 检测到多个根项目 ($item_count),解压至目录: $base_name/"
|
||||||
# mkdir -p "$base_name"
|
mkdir -p "$base_name"
|
||||||
# 7z x -mmt=on "$file" -o"$base_name"
|
7z x -mmt=on "$file" -o"$base_name"
|
||||||
# else
|
else
|
||||||
# # 如果根部只有一个项目,直接解压到当前目录
|
# 如果根部只有一个项目,直接解压到当前目录
|
||||||
# echo "📄 检测到单个根项目,直接解压..."
|
echo "📄 检测到单个根项目,直接解压..."
|
||||||
# 7z x -mmt=on "$file"
|
7z x -mmt=on "$file"
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
|
|
||||||
abbr -a port 'sudo ss -tulnp | grep'
|
abbr -a port 'sudo ss -tulnp | grep'
|
||||||
abbr -a process 'ps aux | grep'
|
abbr -a process 'ps aux | grep'
|
||||||
Reference in New Issue
Block a user