DEV Community

Vincent Jang
Vincent Jang

Posted on

2 2

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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay