7

Is it possible to change the working directory for new integrated terminal windows in Visual Studio Code?

I have opened the folder /path/to/project in Code, so when I open a new terminal windows, it starts in that folder. I would like the terminal to open in /path/to/project/app so that I don't have to cd to that folder every time. Is it possible to configure this in settings.json?

1

2 Answers 2

10

It turns out this was fairly easy to find in the documentation at https://code.visualstudio.com/docs/getstarted/settings.

The setting that controls this is

  // An explicit start path where the terminal will be launched, this is used
as the current working directory (cwd) for the shell process. This may be
particularly useful in workspace settings if the root directory is not a convenient cwd.
  "terminal.integrated.cwd": "",

This can be added to settings.json in the .vscode folder. Absolute and relative paths are supported, so

"terminal.integrated.cwd": "app"

and

"terminal.integrated.cwd": "/path/to/project/app"

will both work.

Sign up to request clarification or add additional context in comments.

Comments

1

if you are changing your directory in your .bashrc or .zshrc file to your home directory (cd ~/ or cd $HOME/) then your vscode console will use the directory that you have specified.

Bellow is a little code you can use in your .bashrc or .zshrc to address this:

if [ "$NAME" != "Code ]; then
  cd ~
else
  cd $OLDPWD
fi

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.