Open vscode in wsl2

.zshrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
CODE_PATH=`which code`

get_real_path(){
real_path="`pwd`"/$1
[[ $1 =~ ^/.* ]] && real_path=$1
[[ $1 =~ ^~.* ]] && real_path=$HOME${1: 1}
echo $real_path
}

get_wsl_path(){
echo \\\\\\wsl$\\kali-linux$(get_real_path $1)
}

get_wsl_uri(){
echo file://wsl$/kali-linux$(get_real_path $1)
}

alias wcode='wcode(){ ${CODE_PATH%%bin/code*}Code.exe $(get_wsl_path $1) 1> /dev/null};wcode'
alias edge='edge(){ /mnt/c/Program\ Files\ \(x86\)/Microsoft/Edge/Application/msedge.exe $(get_wsl_uri $1) };edge'