Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows terminal ubuntu how to change starting directory

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/

like image 650
Mathias Strohkirch Avatar asked May 15 '20 00:05

Mathias Strohkirch


People also ask

How do I change the startup directory in Ubuntu?

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.

How do I change the default path in Windows Terminal?

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.

How do I change my home directory in terminal?

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).

How do I change the default directory in Ubuntu terminal?

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).

How do I change the starting Directory of a terminal?

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.

How do I start Ubuntu from the command line?

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.

What is the default working directory for Windows Terminal?

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.


Video Answer


2 Answers

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.

like image 145
alexzshl Avatar answered Dec 18 '22 06:12

alexzshl


This works for me (on Windows Terminal 1.0.1401.0, WSL2 and Ubuntu 20.04):

"startingDirectory": "C:/Users/user"
like image 23
Oscar Siauw Avatar answered Dec 18 '22 04:12

Oscar Siauw