Tech
[程序员] 赛博后悔药
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 中,这样所有删除都会进入回收站
Read the full discussion on V2EX
This article was aggregated from V2EX. Click to join the conversation.
View on V2EX