Skip to content

Instantly share code, notes, and snippets.

@pwang2
Last active October 31, 2022 05:24
Show Gist options
  • Save pwang2/c7454abfe80f740a941f0d9f6368c387 to your computer and use it in GitHub Desktop.
Save pwang2/c7454abfe80f740a941f0d9f6368c387 to your computer and use it in GitHub Desktop.
open windows file using wsl nvim
@echo on
set my_app=/home/linuxbrew/.linuxbrew/bin/nvim
set my_wt_profile="Ubuntu"
set pp=%1
:: remove quote
set pp=%pp:"=%
:: wsl can't handle mapped drive
if "%pp:~1,1%"==":" (
if not "%pp:~0,1%"=="C" (
code %pp%
call exithere
)
)
:: handle relative path
if not "%pp:~0,2%"=="C:" (
set pp=%pp:.\=%
set pp=%cd%\%pp%
)
set pp=$(wslpath '%pp%')
echo %pp%
set launch="%my_app% \\"^""%pp%\\"^""
start wt.exe new-tab -p %my_wt_profile% bash -i -c %launch%
:exithere
exit
:: GistID: c7454abfe80f740a941f0d9f6368c387
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment