Skip to content

Instantly share code, notes, and snippets.

@igrep
Last active November 10, 2023 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igrep/6f40888aab6268c1d4b4c89a27122627 to your computer and use it in GitHub Desktop.
Save igrep/6f40888aab6268c1d4b4c89a27122627 to your computer and use it in GitHub Desktop.
Abuse unison's -sshcmd option to synchronize with the VM on WSL without sshd.
> unison C:\unison-test ssh://user@localhost/unison-test -retry 0 -repeat watch -sshcmd C:\\double\\backslashes\\path\\to\\wsl-as-ssh.cmd
@echo off
set "USER_NAME="
rem ESCAPE_CHAR perhaps isn't helpful for WSL
rem set "ESCAPE_CHAR="
rem PORT perhaps isn't helpful for WSL
rem set "PORT="
set "HOST_NAME="
set "COMMAND="
:PARSE_ARGS
if "%~1"=="" goto :END_PARSE_ARGS
if "%~1"=="-l" (
set "USER_NAME=%~2"
shift
) else if "%~1"=="-p" (
rem set "PORT=%~2"
shift
) else if "%~1"=="-e" (
rem set "ESCAPE_CHAR=%~2"
shift
) else (
if not defined HOST_NAME (
set "HOST_NAME=%~1"
) else (
set "COMMAND=%COMMAND% %~1"
)
)
shift
goto :PARSE_ARGS
:END_PARSE_ARGS
wsl --cd "~" -u %USER_NAME% -- %COMMAND%
@igrep
Copy link
Author

igrep commented Oct 19, 2023

NOTE: Most of the wsl-as-ssh.cmd is written by ChatGPT (GPT 3.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment