LoginSignup
25
14

More than 3 years have passed since last update.

Windows Terminal で WSL を開くときに開始されるディレクトリを $HOME にする

Posted at

やりたかったこと

Windows Terminal で、 WSL を開くと C:\Windows\system32 (/mnt/c/WINDOWS/System32) が開始ディレクトリになっている。これを $HOME に変更したい。

やったこと

wsl.exe のパラメーターで指定した。

"commandline" : "wsl.exe ~ -d Ubuntu-18.04",

至るまでの過程

profile.json にて 各種 profile の項目がある。


{
    "globals" : 
    {
    },
    "profile" :
    [
        {
        "commandline" : "powershell.exe",
        "startingDirectory" : "%USERPROFILE%"
        },
        {
        "commandline" : "cmd.exe",
        "startingDirectory" : "%USERPROFILE%"
        },
        {
        "commandline" : "wsl.exe -d Ubuntu-18.04"
        }
    ]
}

powershell.execmd.exe の profile には startingDirectory と、指定する項目がある。しかし、これは Windows 側のフォルダ指定なので wsl.exe の profile で startingDirectory を指定しても、 Linux 側のディレクトリには移動できない。

wsl.exe は linux 側の実行コマンドなので、そこで指定することにした。

ほかの方法

commandline の項目を wsl.exe から、 ubuntu1804.exe とかの、ディストリビューションのコマンドにする。 なお、 bash.exe はダメでした。

ダメだった方法

startingDirectory//WSL$/[distributionName][directory] を入れるという方法があるみたいだが、私にはできなかった。

参考URL

startingDirectory setting issue for wsl profile #592

検索キーワード

以下のキーワードを Google Search で探した。

windows terminal wsl start default directory

感想

最近の Microsoft は GitHub で活動しているので、GitHub Issues で探した方が、早く見つかる気がする。
Windows Terminal とか Windows Subsystem for Linux とか Visual Studio Code とか。

25
14
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
14