I am wondering how to change the starting directory of my windows terminal from /home/user/
to C:/Users/user
. I tried a few things I found, but nothings works. This is my current profile specified in the settings.json file:
{
"acrylicOpacity" : 1,
"closeOnExit" : true,
"colorScheme" : "One Half Dark",
"commandline" : "ubuntu",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "Consolas",
"fontSize" : 10,
"guid" : "{ba50f801-2d96-4517-a737-575f32f0fb61}",
"historySize" : 9001,
"icon" : "C:/Users/user/Pictures/ubuntu.png",
"name" : "Ubuntu",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"startingDirectory" : "C:\\Users\\user",
"useAcrylic" : true
}
but when I open the terminal the prompt is user@laptop:~$
and pwd
gives /home/user/
Changing Ubuntu's Starting Directory in Windows Terminal Anyway, the solution is simple and takes about a minute at most: just add a cd command to change the directory in the user's bash configuration file (/home/<user>/. bashrc). For example, say we want the Ubuntu shell to start in the user's home directory.
Open the settings editor from the drop-down menu in Windows Terminal, or hit Ctrl+, on Windows. Modify the startingDirectory setting from your settings file. Save. Voila.
cd ~ (the tilde). The ~ means the home directory, so this command will always change back to your home directory (the default directory in which the Terminal opens).
You can use the same line of code that you used above to change Ubuntu’s (Linux) default directory in Windows Terminal. To do this, open the Windows Terminal’s settings file. Scroll to the section where it says “Name : Ubuntu.” Put your cursor after the last value in this section and add a, (comma).
Modify the startingDirectory setting from your settings file. Save. Voila. Modify the starting directory for your Windows Terminal settings file. Sure enough, you can also configure different starting directories for different terminals. Here's one way to do that.
This command line invokes WSL and ask it to start "Ubuntu" which is done in the current directory, i.e. if you run wsl.exe -d Ubuntu while in Desktop of Windows, Ubuntu will start on Windows' Desktop. As a workaround, you can modify the command line and use one of the below.
Windows Terminal uses your current user directory as the default directory when you open it. However, you can change this to any directory on your Windows PC. We’ll show you how to change the default working directory for PowerShell, Command Prompt, and Ubuntu shell. PowerShell is the default shell that opens when you launch Windows Terminal.
If you mean wsl
, you can set startingDirectory
just like this:
"startingDirectory": "//wsl$/Ubuntu/home/user"
You can explore the path \\wsl$
in Windows Explorer.
This works for me (on Windows Terminal 1.0.1401.0, WSL2 and Ubuntu 20.04):
"startingDirectory": "C:/Users/user"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With