推荐阅读
mac 中直接就能调用 open xxx
打开文件夹,wsl2 中也可以有。
你可以调用 open what-dir
/ open test.txt
直接打开目录。
新建文件 ~/bin/open
填入以下内容
#!/bin/bash
target="$1"
if [ -z "$1" ]; then
target=$(pwd)
fi
if [ ! -e "$target" ]; then
echo "Error: '$target' does not exist."
exit 1
fi
if [ -d "$target" ]; then
abs_path=$(realpath "$target")
else
abs_path=$(dirname "$(realpath "$target")")
fi
# 转为 Windows 路径
win_path=$(wslpath -w "$abs_path")
# 打开
explorer.exe "$win_path"
为文件添加执行权限
chmod +x ~/bin/open
添加到系统路径
export PATH="$HOME/bin:$PATH"
如非特别声明,本站作品均为原创,遵循【自由转载-保持署名-非商用-非衍生 创意共享 3.0 许可证】。
对于转载作品,如需二次转载,请遵循原作许可。