How to change the default directory in Windows Terminal

How to change the default directory in Windows Terminal

Loading


2021-05-13 16:28:12

By default, Windows Terminal will use your current user folder as the default folder when you open it. However, you can completely change this folder to any other folder on your Windows PC. In this article, we will learn how to change the default working directory for PowerShell, Command Prompt and Ubuntu shell.

Change PowerShell’s default directory in Windows Terminal

PowerShell is the default shell that opens when you launch Windows Terminal. Like other shells, PowerShell uses your current user directory as the default directory.

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

To get started, open the menu “Start“, search “Windows Terminal”And click on the corresponding application in the returned result.

Next, click the down arrow icon at the top of the Windows Terminal window, then select “Settings“.

Select

Windows will ask you which application you want to open the installation file to. You can choose any code editor (or plain text) from the list, but we recommend using Notepad for simplicity. Click on “Notepad“In the list and press”OK“.

Notepad

Once the setup file opens in Notepad, scroll to the “Make changes here to the powershell.exe profile“.

Place your cursor at the end of the last value in this section and enter a “,” (comma).

For example, if the final value in that section is:

"Hidden": false

Now it should look like this (notice the comma at the end.):

"Hidden": false,

Notice the comma at the end

Next, press Enter to add a new line. Enter the following code in this line, replacing the PATH with the path to your new default directory.

Make sure that your directory path has quotation marks. Also, when you have a slash in the path, set it to double slash.

"startingDirectory": "PATH"

For example, to set your desktop as the default folder, you have to enter the following line of code in the setup file (instead “Username“by your username):

"startingDirectory": "C:UsersUsernameDesktop"

Enter the corresponding folder name

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

File> Save” width=”560″ height=”403″ class=”lazy” data-src=”https://st.CHK.com/photos/image/2021/04/17/thay-doi-thu-muc-mac-dinh-trong-windows-terminal6.jpg”/></p>
<p>From now on, when you open a new PowerShell tab in Windows Terminal, it will use the folder you just specified as the new default folder.</p>
<h2>Change the default Command Prompt folder in Windows Terminal</h2>
<p>You can also change the Command Prompt’s default directory using the same steps as listed above.  The only difference is that you need to add the new folder path in the Command Prompt section of the setup file.</p>
<p>First, open the Windows Terminal settings as shown above.</p>
<p>Scroll down to the “<strong>Make changes here to cmd.exe profile</strong>“.</p>
<p>Place your cursor after the last value in this section and enter a “<strong>,</strong>” (comma).</p>
<p>Press Enter to add a new line and enter the following code.  Replace the PATH value with the path to your new directory.</p>
<pre>Bấm File > Save trong Notepad để lưu các thay đổi của bạn.

Change Ubuntu’s default directory in Windows Terminal

You can use the same line of code above to change Ubuntu (Linux) default directory in Windows Terminal.

First, open the Windows Terminal installation file as you normally would.

Scroll to the section that says “Name: Ubuntu.

Place your cursor after the last value in this section and add a “,” (comma).

Press Enter to add a new line and enter the following code, of course you will still have to replace the PATH value with the path to your new directory.

"startingDirectory": "PATH"

Enter the code

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

How to reset the default folder in Windows Terminal

To revert back to the original default folder in Windows Terminal, simply remove your newly added code from the installation file.

Start by opening Windows Terminal and then launching the installation file.

Go to the shell where you want to reset the default directory.

Use your mouse to highlight the entire line of code you added earlier, then press Backspace to delete it.

Delete this line

Also, remember to remove the “,”(Comma) that you added to the end of the last value in that section.

Finally, click File> Save in Notepad to save the changes.

.

#change #default #directory #Windows #Terminal

Leave a Reply

Your email address will not be published. Required fields are marked *