Open Emacs GUI in WSL2 through X server conveniently
Add shortcut and context menu item for Emacs in Windows.
The scripts will start X server automatically.
-
Open powershell as administrator
-
Set powershell executionPolicy
Set-ExecutionPolicy Unrestricted
-
Copy
emacs_start.sh
to wsl user's home. -
Edit
powershellScriptPath
inemacs_start.vbs
.powershellScriptPath="D:\emacs\wsl-emacs-contextmenu\emacs_start.ps1"
-
Edit some variables in
emacs_start.ps1
.$wslUserName = "smj" $xServerPath = "D:/mobaxterm/MobaXterm.exe" $xServerProcessName = "mobaxterm" $xServerOptions = " -hideterm" $wsl = "ubuntu.exe"
-
Edit paths in
EditWithEmacs.reg
. -
Import registry
EditWithEmacs.reg
. -
Copy
Emacs GUI.lnk
to your desktop and modify its property, or create a new shortcut on yourself. -
if some error occurs, set
visible
inemacs_start.vbs
to1
and see what happened. -
emacs_start.sh
set some environment variables for the X server, modify it if you need.