[VSCode]ターミナルから直接remote sshやWSLを開く

VSCodeを一旦起動して、サイドバーから選ぶのは面倒。

ローカルのフォルダ内だったらcode /rootで開けるが、remote sshやwslディストリビューションでもコマンド一発で開ける。

remote ssh

code –remote ssh-remote+[ホスト] [ディレクトリ名]

code --remote ssh-remote+remote_server /code/my_project

ホストはSSH TARGETSに記載されているものと同じ

Visual Studio Code Remote Development Troubleshooting Tips and Tricks
Visual Studio Code Remote Development troubleshooting tips and tricks for SSH, Containers, and the Windows Subsystem for Linux (WSL)

wslディストリビューション

code remote wsl+[ディストリビューション名] [ディレクトリ名]

code remote wsl+Ubuntu /root

また、ディストリビューション名はwsl --listコマンドで確認することができる。


https://code.visualstudio.com/docs/remote/wsl#_getting-started

docker コンテナ

2022/6/1現在、ターミナルからdockerコンテナへの直接アタッチは対応していない。

理由は内部で特殊なアドレスを使用しているため(時間があればもうちょっと調査してみます)

function u1(t, e, r) {
  let n = JSON.stringify({ containerName: t, settings: e, cwd: r });
  return `attached-container+${Buffer.from(n, "utf8").toString("hex")}`;
}

コメント

タイトルとURLをコピーしました