reddit / emacs

Start emacs on wsl from windows file explorer.

O10120240501 · 2022-11-12 11:27
I'm trying to create a script so I can use it with windows open-with in file explorer, it's supposed to pass the filenames to emacs but here is the problem: Emacs.bat: ``` wsl bash -c ". ~/.bash_profile && emacs %*" ``` (. bash\_profile is needed to export variables for x server to work properly) %* is expanded to windows style filenames with \\ instead of / I tried to work around this by passing these arguments to bash script: Emacs.bat: ``` wsl bash -c ". ~/.bash_profile && ~/.emacs.d/windows-open %*" ``` windows-open: ``` #!/bin/sh echo "$@" | tr '\\' '/' # see how it expands # emacs $(echo "$@" | tr '\\' '/') ``` and trying to run: ``` PS C:\Users\wisni> .\bin\Emacs.bat "te\st lmao" C:\Users\wisni>wsl bash -c ". ~/.bash_profile && ~/.emacs.d/windows-open "te\st lmao"" test ``` as you can see only the first word of was passed to the script (te\st) and \s was somehow escaped by the shell to just s. I had tried to use single quote instead of double quotes: ``` wsl bash -c '. ~/.bash_profile && ~/.emacs.d/windows-open %*' ``` but it breaks even more badly: ``` PS C:\Users\wisni> .\bin\Emacs.bat "te\st lmao" C:\Users\wisni>wsl bash -c '. ~/.bash_profile && ~/.emacs.d/windows-open "te\st lmao"' /bin/bash: -c: line 0: unexpected EOF while looking for matching `'' /bin/bash: -c: line 1: syntax error: unexpected end of file ``` any idea how to do it?
ConfusedOnCOFFEE · 2022-11-12 17:03
You need to install VcXsrv and expose it to the WSL. With WSL2 I think, you don’t need it anymore. It‘a sharing your window frame.