How to change the default directory in Windows terminal

Contents

Windows terminal with a command prompt shell.

Windows Terminal uses your current user directory as the default directory when you open it. Despite this, you can change this to any directory on your Windows PC. We will show you how to change the default working directory for PowerShell, Ubuntu command prompt and shell.

Change default PowerShell directory in Windows terminal

PowerShell is the default shell that opens when you start Windows Terminal. In the same way as other shells, this uses your current user directory as the default.

You can change this default directory by adding a single line of code in the Windows Terminal configuration file.

To do this, open the menu “Beginning”, I searched “Windows Terminal” and click the app in the results.

open windows terminal

Click the down arrow icon at the top of the Windows Terminal window and then select “Setting”.

Access the Windows terminal settings

Windows will ask you which application you want to open the configuration file with. You can select any code editor (or plain text) of the list, but we'll stick with Notepad for the sake of simplicity. Click on “Notepad” in the list and press “To accept”.

Open Windows Terminal settings in Notepad

When the configuration file opens in Notepad, scroll to the section “Make changes here to the powershell profile.exe”.

place the cursor at the end of the last value in this section and type a, (coma).

As an example, if the last value in that section was:

"Hidden": false

Now it would look like this (see the comma at the end):

"Hidden": false,

add a comma after a value in windows terminal

Now, press enter to add a new line. type the following code on this line, replacing PATH with the path to its new default directory.

Make sure your directory path is in double quotes. At the same time, when you have only one bar on the route, turn it into a double bar.

"startingDirectory": "PATH"

As an example, to set your desktop as the default directory, you should write the next line of code in the config file (replacing “Username” with your username):

"startingDirectory": "C:UsersUsernameDesktop"

Change default PowerShell directory

After entering the route, click File> Save to Notepad to save your changes.

Save Windows terminal settings

Now, when opening a new PowerShell tab in Windows Terminal, will use your newly specified directory as the default directory.

Change default directory of command prompt in Windows terminal

You can change the default directory of the command prompt by following the same steps as previously listed. the only difference is that you must add the new directory path in the command prompt section of the configuration file.

To do this, open windows terminal settings as you did previously.

Scroll down to the section “Make changes here to the cmd profile.exe”.

place the cursor after the last value in this section and type a, (coma). press enter to add a new line and then type the following. be sure to replace path with your new directory path.

"startingDirectory": "PATH"

Change the default directory of the command prompt

Select File> Save to Notepad to save your changes.

Change Ubuntu's default directory in Windows terminal

You can use the same line of code you previously used to change Ubuntu's default directory (Linux) in Windows Terminal.

To do this, open the Windows Terminal configuration file.

Scroll to the section where it says “Name: Ubuntu”.

Place the cursor after the last value in this section and add a, (coma).

Press Enter to add a new line and write this code on that line. Replace PATH with the path to your new default directory.

"startingDirectory": "PATH"

Change Ubuntu's default directory

In the Notepad window, click File> Save to save changes.

How to reset the default directory in Windows terminal

To revert to the original default directory in Windows Terminal, you just need to remove the newly added code from the config file.

Start by opening the Windows Terminal and then run the configuration file.

Navigate to the shell for which you want to reset the default directory.

Use your mouse to highlight the entire line of code that you previously added, then press Backspace to remove that line.

Reset default directory in Windows Terminal

At the same time, be sure to remove the (coma) which you added to the end of the last value in that section.

In summary, click File> Save to Notepad to save your changes.

Are you ready.


Did you know that Windows Terminal offers many customization options? You can use these options to change the look and feel of this tool on your computer..

RELATED: How to customize the new Windows terminal application

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.