Last active
October 31, 2022 05:24
-
-
Save pwang2/c7454abfe80f740a941f0d9f6368c387 to your computer and use it in GitHub Desktop.
open windows file using wsl nvim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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