赛博后悔药

andforce 2026-08-31 18:21 1

 unalias rm 2>/dev/null
function rm {
local args=()
for arg in "$@"; do
case "$arg" in
-*) ;; # 跳过所有 flag ,只保留文件路径
*) args+=("$arg") ;;
esac
done
if [[ ${#args[@]} -eq 0 ]]; then
echo "rm: missing operand"
return 1
fi
trash "${args[@]}"
}

放到 Mac 的 ~/.zshrc 中,这样所有删除都会进入回收站

最新回复 (3)
  • liuxue 08-31 22:10
    1
    如果 ai 不使用你的环境变量,不还是会出问题么
  • ruanimal 09-01 10:56
    2
    你没有用过 trash-cli 吗? 另外 ai 很喜欢用绝对路径,alias 其实作用也不大
  • cheng6563 09-01 11:38
    3
    windows ,让 AI 糊了个 sbox.md ,sbox codex 这样启动 codex ,就建一个 sandboxie 区,只给当前目录设置完全访问,其他目录全走 sandboxie
* 帖子来源V2EX
返回