Batch file 从windows打开带有EmacClient的文件

Batch file 从windows打开带有EmacClient的文件,batch-file,emacs,windows-subsystem-for-linux,wsl-2,Batch File,Emacs,Windows Subsystem For Linux,Wsl 2,我尝试在Windows10中运行在wsl2/Debian上的EmacClient中打开一个文件 启动时,我启动wsl/debian、X410作为X-server和emacs守护进程 我可以使用以下startclient.bat使用EmacClient启动新的emacs框架: @echo off debian.exe run "if [ -z \"$(pidof emacsclient)\" ]; then export DISPLAY=$(cat /etc/res

我尝试在Windows10中运行在wsl2/Debian上的EmacClient中打开一个文件

启动时,我启动wsl/debian、X410作为X-server和emacs守护进程

我可以使用以下startclient.bat使用EmacClient启动新的emacs框架:

@echo off

debian.exe run "if [ -z \"$(pidof emacsclient)\" ]; then export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0; emacsclient -c; pkill '(gpg|ssh)-agent'; fi;"
然后我创建了一个快捷方式,这样我就可以从任务栏打开一个新的emacs框架。令我惊讶的是,它工作得相当顺利。。。目前为止但是,我不知道如何从windows资源管理器中使用EmacClient打开文件

我想我需要在bat文件中向EmacClient-c传递一个参数,但是我该怎么做呢

编辑: 通过执行以下操作:

debian.exe run "if [ -z \"$(pidof emacsclient)\" ]; then export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0; emacsclient -c "%1"; pkill '(gpg|ssh)-agent'; fi;"
我可以通过以下方式使用EmacClient打开文件:

startclient.bat file.txt
但是,当使用open时,文件的路径会出错 而不是

/mnt/c/Users/path/to/file
我明白了


如何将正确的路径作为变量传递?

不太确定
/mnt/c/Windows/system32/
是从哪里来的,但是您可以将
c:\Users\path\to\file
转换为
/mnt/c/Users/path/to/file
,方法是将
%1
参数包围起来,例如:


emacsclient-c“$(wslpath“%1”)”

不太确定
/mnt/c/Windows/system32/
来自何处,但您可以将
c:\Users\path\to\file
转换为
/mnt/c/Users/path/to/file
,方法是将
%1
参数包围起来,如下所示:

EmacClient-c“$(wslpath“%1”)”

/mnt/c/Windows/system32/C:\Users\path\to\file