Windows Terminal uses your current user directory because the default directory once you open it. However, you’ll change this to any directory on your Windows PC. We’ll show you ways to vary the default working directory for PowerShell, prompt , and Ubuntu shell.
Change PowerShell’s Default Directory in Windows Terminal
PowerShell is that the default shell that opens once you launch Windows Terminal. Like other shells, this one uses your current user directory because the default.
You can change this default directory by adding one line of code within the Windows Terminal’s settings file.
To do this, open the “Start” menu, look for “Windows Terminal,” and click on the app within the results.
Click the down-arrow icon at the highest of the Windows Terminal window, then select “Settings.”
Windows will ask what app you would like to open the settings file with. you’ll choose any code (or plain-text) editor within the list, but we’ll persist with Notepad for the sake of simplicity. Click “Notepad” within the list and hit “OK.”
When the settings file opens in Notepad, scroll to the “Make changes here to the powershell.exe profile” section.
Put your cursor at the top of the last value during this section and sort a , (comma).
For example, if the last value therein section was:
It would now look like this (See the comma at the end.):
Now, press Enter to add a new line. Type the following code in this line, replacing PATH with the path to your new default directory.
Make sure that your directory path is enclosed with double quotes. Also, where you have a single slash in the path, make it a double slash.
For instance, to set your desktop as the default directory, you’d type the following line of code in the settings file (replacing “Username” with your username):
After entering the path, click File > Save in Notepad to save your changes.
Now, when you open a new PowerShell tab in Windows Terminal, it’ll use your newly specified directory as the default directory.
Change Command Prompt’s Default Directory in Windows Terminal
You can change Command Prompt’s default directory using the same steps as those listed above. The only difference is that you need to add the new directory path in the Command Prompt section of the settings file.
To do this, open Windows Terminal’s settings like you did previously.
Scroll down to the “Make changes here to cmd.exe profile” section.
Put your cursor after the last value in this section, and type a , (comma). Press Enter to add a new line and type the following. Be sure to replace PATH with your new directory path.
Select File > Save in Notepad to save your changes.
Change Ubuntu’s Default Directory in Windows 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).
Press Enter to add a new line and type this code in that line. Replace PATH with the path to your new default directory.
In your Notepad window, click File > Save to save your 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 your newly added code from the settings file.
Start by opening Windows Terminal and then launching the settings file.
Scroll to the shell that you want to reset the default directory for.
Use your mouse to highlight the entire line of code that you added previously, then press Backspace to delete that line.
Also, make certain to get rid of the , (comma) that you simply added to the top of the last value therein section.
Finally, click File > Save in Notepad to save lots of your changes.
You’re ready .