blog posts

PowerShell

How to Set the Default Starting Directory in Windows Terminal for PowerShell and Command Prompt

Windows Terminal is one of the most powerful command execution platforms In The Windows Operating System. If you know how it works, It Can Facilitate Many Different Processes And Functions. 

This platform, accessible via PowerShell or CMD, can help users in areas that cannot be done through the graphical interface. Therefore, users, especially those who have previously worked with other existing platforms such as Linux, are expected to be familiar with the platform. It is prevalent.

If you constantly use Windows Terminal, you must have noticed by now that this platform’s default directory is in the path of the username folder.

However, it is possible to change the directory through the terminal using the “cd” command as quickly as possible or by holding down the Shift key and then right-clicking and selecting one of the Open PowerShell windows here or Open CMD window here options.

You can change the directory, but doing it repeatedly can be a little tedious over time (especially since you also need constant access to the terminal through a particular directory).

Fortunately, changing the default Windows terminal path is possible by adding a command line to the platform’s settings file. In this article, we will learn how to do it together.

Change the default terminal directory in PowerShell

First, open the Start menu, and after searching for Windows Terminal, click on the displayed application in the search list.

Change the default terminal directory in PowerShell

Note: The terminal platform is not included by default in Windows; to use it, it must be downloaded as separate software and then installed.

Click on this link to download this application from the Microsoft Store.

Click on this link to download this application from the Microsoft Store.

After running the terminal software, click on the platform change icon, which is an arrow pointing downwards. Then, select the Settings option from the shortcut menu displayed. You will see that the default application selection window is displayed.

After running the terminal software, click on the platform change icon, which is an arrow pointing downwards. Then, select the Settings option from the shortcut menu displayed. You will see that the default application selection window is displayed.

Suppose another page is displayed to change the default values after selecting the settings option. In that case, it is enough to click on the Open JSON file option at the bottom left of the same window to run the settings configuration file.

Suppose another page is displayed to change the default values after selecting the settings option. In that case, it is enough to click on the Open JSON file option at the bottom left of the same window to run the settings configuration file.

You can now open Windows Terminal Settings with your favorite text editor software. In this article, the familiar name application Notepad has been used to simplify the instructions.

You can now open Windows Terminal Settings with your favorite text editor software. In this article, the familiar name application Notepad has been used to simplify the instructions.

After running the settings text file with the Notepad tool, drag the page down and find the “Make changes here to the PowerShell.exe profile” section.

Place the mouse pointer at the end of the last visible value in this section and then type the comma (,) character.

Now press the Enter key to move to the new line, and then type and add the following command to change the default directory. Remember that the PATH phrase must be replaced with the path you want, and all values ​​must be enclosed in quotation marks.

“startingDirectory”: “PATH”

For example, suppose we want to redirect the default directory to the Desktop. To do this, the new command line must be added to the settings as follows: (again, the Username must be replaced with your account name).

“starting directory”: “C:\\Users\\Username\\Desktop”

For example, suppose we want to redirect the default directory to the Desktop. To do this, the new command line must be added to the settings as follows: (again, the Username must be replaced with your account name).

After redirecting, click the Save button from the File menu to save the settings. The default directory of the PowerShell platform via the Windows terminal tool will change to the specified path every time you open it.

Change the default terminal directory in the Command Prompt

Changing the default terminal directory on the Command Prompt platform, or CMD for short, is done just like PowerShell, except that the command for the new path must be added to another part of the configuration text file.

To do this, rerun the previous instructions and open the Windows terminal configuration file using Notepad software.

Now, drag the page down and find the “Make changes here to cmd.exe profile” section.

Now, add the command line for the new directory according to the instructions mentioned in the previous section and save the file.

Change the default terminal directory in the Command Prompt

Delete the directory. Add and restore the default path.

This action is also possible by deleting the new command line added to the desired platform (PowerShell or CMD).

Open the Windows terminal settings file again, as described earlier. Go to the platform, select the entire directory channel link, and delete it by pressing the Backspace key on the keyboard. Do not forget to delete the comma (,) character.

Delete the directory. Add and restore the default path.

FAQ

How can I change the default starting directory in Windows Terminal?

Open Windows Terminal, click the down arrow (v) in the title bar, and select "Settings." In the settings UI, navigate to the profile you wish to modify (e.g., PowerShell or Command Prompt). Under the "Starting directory" section, enter your desired path, such as C:UsersYourUsernameDocuments. Save the changes, and the terminal will open to this directory by default.

Can I set different starting directories for each profile?

Yes, you can configure unique starting directories for each profile. In the settings UI, select each profile individually and specify a different path in the "Starting directory" field. This allows you to have PowerShell open in one directory and Command Prompt in another, tailored to your workflow needs.

Is there an alternative method to change the starting directory using the settings.json file?

Absolutely. If you prefer editing the configuration file directly, open the settings.json file by clicking the down arrow (v) in the title bar and selecting "Settings" > "Open JSON file." Locate the profile you wish to modify and add or edit the "startingDirectory" property with your desired path, like "startingDirectory": "C:\Users\YourUsername\Documents". Save the file, and the changes will take effect the next time you open the terminal.