Skip to content

Instantly share code, notes, and snippets.

@danielrothfus
Created September 4, 2017 03:20
Show Gist options
  • Save danielrothfus/6e93df514be08cad5b61b130188b3057 to your computer and use it in GitHub Desktop.
Save danielrothfus/6e93df514be08cad5b61b130188b3057 to your computer and use it in GitHub Desktop.
Launch emacs in the Linux subsystem for Windows
REM Launch emacs in the Linux subsystem for Windows for a quoted filename.
REM Daniel Rothfus
REM Sept 3, 2017
REM
REM To add Linux emacs as a right-click item in the context menu, add a registry
REM key at Computer\HKEY_CLASSES_ROOT\*\shell\emacs\command with the default
REM value "C:\...\launch_emacs.bat" "%1". Set the parent key's default value to
REM the entry's desired name, such as "Launch in Emacs".
REM
REM This script is an MVP and as such it probably has many edge cases around
REM characters allowed in Windows paths that are interpreted differently in a
REM bash shell.
@echo off
set arg1=%1
set "path=%arg1:~1,-1%"
set "crel=%path:C:=%"
set "r1=%crel:\=/%"
set "r2=%r1: =\ %"
"C:\Windows\System32\bash" -c "emacs /mnt/c%r2%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment