Skip to main content how to change vs code terminal directory path to curent workspace folder : r/cs50
r/cs50 icon
Go to cs50
•

how to change vs code terminal directory path to curent workspace folder

IDE

Hey i need help with VS code terminal ...

so suppose i opened a "project" folder in vscode

and powershell terminal inside vscode showing directory path like this: PS D:\work\project>

and now inside "project" in vs code as task required, If i create some more nested Folders and file suppose(hello\hello.py) and now vs code powershell terminal showing path like this: PS D:\work\project\hello>

but i want terminal directory path to start from "project" , something like PS project\hello>

how to achieve this ?

So basically in vs code if i open a folder terminal should start its directory path from that folder

Is their any solution to that..

Slash review times, eliminate bugs, and get valuable insights into your projects and code.
  • Slash review times, eliminate bugs, and get valuable insights into your projects and code.
  • Slash review times, eliminate bugs, and get valuable insights into your projects and code.
  • Slash review times, eliminate bugs, and get valuable insights into your projects and code.
  • Sort by:
    Best
    Open comment sort options
    [deleted]
    •

    "I'm new to coding however; I fixed this on my end by following this tutorial https://www.youtube.com/watch?v=M2_v8eTQul4

    Also I had to create a project save in the designated folder in order for the video to work for me.

    Not sure if you still need this or not.

    1. In VS code go to File>Preferences>Settings

    2. Type in cwd or Terminal Integrated

    3. Set your desired start path in the integrated terminal section

    4. Click on Terminal and create new terminal

    Hope this helps!

    With the added note that the value should be ${workspaceFolder}

    More replies
    More replies
    • Open Settings: Click on the gear icon in the lower-left corner and select "Settings" or press Ctrl + ,.

    • Open Settings (JSON): Click on the icon in the top-right corner of the settings pane to open the settings in JSON format.

    • Configure Terminal CWD: Add the following setting to ensure the terminal opens in the directory of the currently active file:jsonCopy code{ "terminal.integrated.cwd": "${fileDirname}" }

    Its works for me !

    You can set up profiles and alias' in bash shells. A quick search turned up this stackoverflow post. Bear in mind when I did cs50 they had a custom cs50 online IDE not vscode. Is the current IDE browser based or desktop based?

    Edit: honestly I'm not sure if I'm even answering the right question your post is hard to read.

    Sorry for typo's, I'll try to explain it again: So if in local desktop version of vscode when i open any project folder, than terminal in vscode (powershell) show directory path info like from D:/work/project (I'm using "D" drive here).

    So, how to change vscode terminal settings so it uses "project" workspace folder as a start of directory path of terminal

    More replies

    I agree with u/MarlDaeSu, your post is not the easiest to read :)

    If you ask how to navigate in the terminal, there is a shorts or section video in one of the first weeks that explains some of the basic commands to use in the terminal.

    cd              // change directory, back to your home
    cd ..           // change directory, one level up
    cd my_folder    // change directory, move down to "my_folder"

    Sorry for confusion, I tried again buy updating the post..

    So my question is not about navigating through the directory..

    In vs code suppose we choose "project_1" as folder

    Than inside which I create "hello" folder than "hello.py"

    So in terminal directory path should look like this

    "PS D:\work\project_1\hello> python hello.py"

    since I'm working in "Project_1" folder, instead of starting from root (D:\work\...........so on..)

    how to make it start from "project_1\hello>"

    More replies

    thank u for this i was trying to change to a diff directory from an existing one so i tried cd my_folder but it wasnt working so i had to mention the absolute path and for some reason still didnt work and then i used this to go back home and then to the directory.

    More replies