首先你需要安装 WSL,最好是 Ubuntu,然后在 WSL 建立以下脚本:
#! /bin/bash
FILE=$1
FILE=${FILE##*\\}
EXT=${FILE##*.}
NAME=${FILE%%.*}
#echo $FILE >> ./filename
#echo $EXT >> ./filename
#echo $NAME >> ./filename
#echo $FILE >> ./filename
if [ $EXT = "zip" ]; then
unzip "$FILE"
elif [ $EXT = "tgz" ]; then
tar -xzvf "$FILE"
elif [ $EXT = "gz" ]; then
gzip -d "$FILE"
elif [ $EXT = "rar" ]; then
unrar x -ad "$FILE"
else
echo "not supported"
fi
sleep 2
然后在 Ubuntu 中安装 unrar, zip, tar 等工具用于解压。之后就是在 Windows 注册表,路径为 \HKEY_CLASSES_ROOT\*\shell,在shell上点击右键->新建->项,命名为 解压至当前目录(随便命名),在刚才那个目录上点击右键->新建->项,命名为command(必须这个名),再新建一个字符串,输入值为:wsl exec sh ~/unzip.sh "%1",其中 ~/unzip.sh 是第一个脚本在 wsl 中的路径,我这里放置在了 home 目录。如果还不明白如何新建右键菜单可以参考这个文章
评论列表: