2021-5-20,修复“特定情况下,文件绝对路径获取错误”的bug
2021-5-23,修复“无删除权限的文件,删除时没有反应”
2021-5-23版:
function FeiZhiLou(){
Array1=(${*// / })
for Value1 in ${Array1[*]}
do
if [ -e ${Value1} ]
then
Value2=$(python -c 'import os;print(os.path.abspath("'${Value1}'"))')
osascript -e'
tell application "Finder"
posix path of ((delete posix file "'${Value2}'") as unicode text)
end tell'
fi
done
}
alias rm=FeiZhiLou
将以上代码添加到~/.zshrc
效果:


2021-5-20版:
function FeiZhiLou(){
Array1=(${*// / })
for Value1 in ${Array1[*]}
do
if [ -w ${Value1} ]
then
Value2=$(python -c 'import os;print(os.path.abspath("'${Value1}'"))')
osascript -e'
tell application "Finder"
posix path of ((delete posix file "'${Value2}'") as unicode text)
end tell'
fi
done
}
alias rm=FeiZhiLou
将以上代码添加到~/.zshrc
效果:

2021-5-19旧版:
function FeiZhiLou(){
Array1=(${*// / })
for Value1 in ${Array1[*]}
do
if [ -w ${Value1} ]
then
pwd1=$(pwd)
pwd2="${pwd1}/${Value1}"
osascript <<EOF
tell application "Finder"
posix path of ((delete posix file "${pwd2}") as unicode text)
end tell
EOF
fi
done
}
alias rm=FeiZhiLou
将以上代码添加到~/.zshrc
效果:

本文介绍了一个用于修正文件删除过程中出现的两个Bug的shell脚本。第一个Bug是在特定情况下获取文件绝对路径时出现错误;第二个Bug是在尝试删除无删除权限的文件时没有反馈。通过使用Python获取文件的绝对路径,并通过AppleScript与Finder应用交互来删除文件,脚本实现了更稳定的文件删除功能。
732

被折叠的 条评论
为什么被折叠?



