Files
dotfiles/bin/zp
FlintyLemming 76262a9179 add fish config
2025-12-19 15:56:18 +08:00

24 lines
864 B
Fish
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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"
# 直接传入 $argv7z 会自动处理多个路径
7z a -tzip -mmt=on -mx=5 "$target" $argv
end