WSL2 `startingDirectory` doesn't work..

vincentjang

Vincent Jang

Posted on March 16, 2022

WSL2 `startingDirectory` doesn't work..

Hello dev friends!
Today I solve kind of simple problem but it might bothers you,
Problem is...

Starting Linux Directory in WSL2 is doesn't work properly

It is little bother me, so I want to fix it follow down below;

{
  "startingDirectory" : //wsl$/Ubuntu/home/<my-user-name>
}
Enter fullscreen mode Exit fullscreen mode

but It's not work.
Maybe this problem is related to using zsh(oh-my-zsh like..)

So I came up a little trick, through edit ~/.zshrc
Insert this line at end of ~/.zshrc

If you use bash, edit ~/.bashrc same way.


# for setting start directory for terminal when wsl2 setting not work.
cd ~/

Enter fullscreen mode Exit fullscreen mode

then, It work nice! But I felt very tiny gap time for switching directory to ~/, Fortunately I feel better now.

If I find a better solution for this problem, I'll be back to post it.

I hope you don't spend your time on the same problem as me.
Thanks.

Official Method Found!

I found MS official Document about setting profile with Window Terminal.
If you using over Window Terminal version 1.12.3472.0, Window Terminal can references Linux file system directly, so edit setting like down below;

{
  "startingDirectory": "/home/<username>",
}
Enter fullscreen mode Exit fullscreen mode

Reference : Window Official Doc

💖 💪 🙅 🚩
vincentjang
Vincent Jang

Posted on March 16, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related