File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3+ set -e
4+
35if [[ " $OSTYPE " == " darwin" * ]]; then
46 realpath () { [[ $1 = /* ]] && echo " $1 " || echo " $PWD /${1# ./ } " ; }
57 ROOT=$( dirname " $( dirname " $( realpath " $0 " ) " ) " )
@@ -9,6 +11,9 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
911 export ELECTRON_ENABLE_LOGGING=1
1012else
1113 ROOT=$( dirname " $( dirname " $( readlink -f $0 ) " ) " )
14+ if grep -qi Microsoft /proc/version; then
15+ IN_WSL=true
16+ fi
1217fi
1318
1419function code() {
@@ -50,4 +55,23 @@ function code() {
5055 exec " $CODE " . " $@ "
5156}
5257
53- code " $@ "
58+ function code-wsl()
59+ {
60+ # in a wsl shell
61+ local WIN_CODE_CLI_CMD=$( wslpath -w " $ROOT /scripts/code-cli.bat" )
62+
63+ local WSL_EXT_ID=" ms-vscode.remote-wsl"
64+ local WSL_EXT_WLOC=$( cmd.exe /c " $WIN_CODE_CLI_CMD " --locate-extension $WSL_EXT_ID )
65+ if ! [ -z " $WSL_EXT_WLOC " ]; then
66+ # replace \r\n with \n in WSL_EXT_WLOC
67+ local WSL_CODE=$( wslpath -u " ${WSL_EXT_WLOC%% [[:cntrl:]]} " ) /scripts/wslCode-dev.sh
68+ $WSL_CODE " $ROOT " " $@ "
69+ exit $?
70+ fi
71+ }
72+
73+ if [ -z ${IN_WSL+x} ]; then
74+ code " $@ "
75+ else
76+ code-wsl " $@ "
77+ fi
You can’t perform that action at this time.
0 commit comments