#author("2022-08-01T06:46:46+09:00","default:ryuichi","ryuichi")
#author("2022-08-01T06:48:44+09:00","default:ryuichi","ryuichi")
* WSLからWindowsのVSCodeを起動 [#i490b987]
** 1. Windows上のcodeのパスを調べる [#q1511ce4]
PS> Get-Command code
CommandType Name Version Source
----------- ---- ------- ------
Application code.cmd 0.0.0.0 C:\software\VSCode\bin\code.cmd
- PowerShell上で上のように調べる
- ここでは '''C:\software\VSCode\bin\code.cmd'''
** 2. WSL上でパスを設定する [#ub6d9303]
*** 2.1 WindowsのパスをLinuxのパスに変換する [#t06f88c9]
$ wslpath 'C:\software\VSCode\bin\code.cmd'
/mnt/c/software/VSCode/bin/code.cmd
- WSL上でwslpathコマンドを実行して、1.で調べたパスを変換する
- ここでは '''mnt/c/software/VSCode/bin/code.cmd'''
*** 2.2 パスをシェルのエイリアスに設定する [#ne8af02a]
$ vi ~/.bashrc
--------------------------------------------
alias code='/mnt/c/software/VSCode/bin/code'
--------------------------------------------
- .bashrcや.bash_aliasesなどのシェルの設定ファイルを開いてエイリアスを設定する
- この時、'''code.cmd''' ではなく、'''code''' とする。'''C:\software\VSCode\bin\''' の中にはWindows用のcode.cmdファイルとLinux用のcodeファイルがあり、WSLでは後者を利用する
*** 2.3 VSCodeの起動 [#q3b29fd5]
$ cd ~/src/myproject
$ code .
- 上のように目的のフォルダに移動して、VSCodeを起動できる
*** 補足 [#f1797e06]
Do you trust the authors of the files in this folder?
Yes I trust the authors
- VScode起動時に上のように警告が出たら、Yesを選べばいい