blog posts

How To Change The Default Windows Terminal Directory In Powershell And Cmd

Windows Terminal Or In Other Words, Windows Terminal Is One Of The Most Powerful Commands Execution Platforms In The Windows Operating System, Which Can Facilitate Many Different Processes And Functions If You Are Familiar With How It Works. 

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

If you are one of those who are constantly using Windows Terminal, you must have noticed by now that the default directory of this platform is in the path of the username folder.

 However, it is possible to change the directory through the terminal using the “cd” command as easily 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 to have constant access to the terminal through a particular directory).

Fortunately, it is possible to change the default Windows terminal path by adding a command line to the settings file of this platform. 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.

 

Note: The terminal platform does not exist by default as part of Windows, and to use it must be downloaded as separate software and then installed.

 Click on this link to download this application through Microsoft Store.

 

After running the terminal software, click on the platform change icon in the form of an arrow downwards and then select the Settings option through the shortcut menu displayed; You will see that the default application selection window is displayed.

 

If another page is displayed to change the default values after selecting the settings option, 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, to simplify the instructions, the familiar name application Notepad has been used.

 

After running the settings text file with the Notepad tool, drag the page down a bit and then 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. Keep in mind 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”

 

After redirecting, click the Save button from the File menu to save the settings. Now every time you open the PowerShell platform via the Windows terminal tool, you will see that its default directory has changed to the specified path.

Change the default terminal directory in 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 a bit and then 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 then save the file.

 

Delete directory Add and restore 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 you want and then select the entire directory change line and delete it by pressing the Backspace key on the keyboard. In addition, keep in mind that you should not forget to delete the comma (,) character.