How do you select the terminal location for every terminal type in a VS Code workspace? - visual-studio-code

I am working in a VS Code workspace with multiple directories. When I open the default terminal (Powershell) it get a prompt asking which of the directory roots I want to open the terminal in.
However, if I open another terminal from the dropdown, it opens at the root location of whichever file that I am currently displaying.
Is there a setting to show this prompt for every new terminal, not just the default one? Specifically for the WSL terminal.

Related

Set the path in portable vscode installation powershell terminal

I have multiple versions of vscode installed on my system with portable mode. I start each of them via a desktop shortcut. Since they are in portable mode, their installation directories are not in the default PATH variable.
When I make a new powershell terminal window, the portable vscode directory is not on the path. I need the command "code" in the terminal window to run the same vscode version that the terminal shell is running in. In other words, if I am running a portable vscode, and I open a powershell terminal and type the command "code", I want it to run the code.exe file that is the same as the vscode I am running it in, and not a different one, and not get the "object not found" message. For various reasons I do not want to have to type the full path.
So, in essence, I want to add a directory to the path variable when vscode starts up, with that directory being the base directory of the vscode itself.
You need to set this in: File/Preferences/Settings then select Workspace, there go to: Terminal/Integrated:Cmd and there specify An explicit start path where the terminal will be launched.

How to make cmd the default terminal that gets opened in VSCode on opening VS Code.?

When I open my VSCode the default terminal that gets opened is PowerShell. I wants the default one that gets opened to be CMD. How can I change it?
I have configured the Terminal: Select Default Profile to be CMD and its also made sure as seen in the below pic.
I restarted the VSCode several times, still on opening VS Code the terminal that gets opened is PowerShell. Should I make any changes to settings.json?

Automatically Open Terminal on start OR New Window

Simple question: 99% of my time spent in VSCode is spent with a terminal open. Is there a setting or an extension that will keep terminal open when I either
A. Start VSCode
OR
B. Open a file / folder in a new window
Are you aware of batch files?
Create a text file with the extension .bat and insert this code to make it open both programs with one user action. Do change the Visual Studio path so it matches your executable location; the example is generic.
start cmd && "C:\Users\{UserName}\AppData\Local\Programs\Microsoft VS Code\Code.exe"

How to open directory from terminal in vs code? but inside the same window

I have vs code open and I'm using bash terminal within it, when I'm inside the directory I want to open I type code . and that opens everything I want but it opens a new vs code window. Is there a way it can open inside of the current vs code window I am in?
Try code . -r to force opening in the same window. See https://code.visualstudio.com/docs/editor/command-line#_core-cli-options for more options in the command line.
For a more "permanent" solution there is this setting:
Window: Open Files In New Window
Controls whether files should open in a new window. Note that there
can still be cases where this setting is ignored (e.g. when using the
--new-window or --reuse-window command line option).
Set it to off and then ``code .` is enough.

Opening a new terminal tab based on the current one

I've added the following keybinding in vscode to open a new terminal window:
{
"key": "cmd+t",
"command": "workbench.action.terminal.new"
}
When I execute a command like cd Desktop then run cmd+t again while still in it, the new terminal starts from zero. Is it possible for the new terminal to be based on the previous one? meaning in our case it should open a new terminal tab that runs on /Desktop instead of the root directory.
I am using bash.
Add the following to your User Settings (Menu:File > Preferences):
"terminal.integrated.cwd": "Desktop"
This will now open up in Desktop instead of having to cd into it.
I'm not sure how to change the cwd based on other open terminals per your question.Here's the full commented setting in vscode:
// 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": "",