All in title. Also i'm russian and this is Google Translate. I opened the process in Task Manager and went to the file location. There was an error with access denial, but it was solved with the help of Computer Control. But I don't know how to open this particular terminal in vs code. I introduced OpenConsole first.Yes, but it was only a terminal. But that's what I'm interested in.
SCREENSHOT
I think you want to launch the new Windows Terminal from within VS Code.
What you need to do is edit your USER settings.json, and locate the line that associates an editor with the integrated Windows terminal (there are three built-in editors that you can redefine:
Windows (cmd or PowerShell)
Windows Subsystem for Linux (wsl)
Linux (xterm)
):
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
If you REPLACE this by:
"terminal.integrated.shell.windows": "C:\\Users\\<your_user_name>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe",
... then your Windows Terminal will pop up rather than the cmd integrated console. But it will be in a separate window (not in the VS Code pane); I am not aware of any method on how to start Windows Terminal in integrated mode...
If it is however your intention to replace the usual cmd terminal by a PowerShell, then you can follow the instructions from Fran6.
A more graphical method is go to your existing VS Code terminal, and go to the drop down to select one of multiple terminals you might have launched. Below your existing terminals, there is an option to 'Select Default Shell':
When you select this option, this will take you straight to the options available to change to your preferred integrated shell:
When you now hit the + next to the dropdown, you can accumulate as many shells as you want, of any type that you want; Here is an example of 2 cmd shells, 1 PowerShell, and one wsl shell:
Update (May 2021):
The terminal.integrated.shell.windows setting is now deprecated.
You should add a profile to terminal.integrated.profiles.windows. For example:
terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": "C:\\WINDOWS\\System32\\cmd.exe"
},
"wt": {
"path": "C:\\Users\\<your_user_name>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"
},
},
Then set it as default:
"terminal.integrated.defaultProfile.windows": "wt",
To use a different shell in vscode:
Use the shortcut Ctrl + Shift + P on your keyboard or go to view >> Command Palette
Type in:
Terminal: select default shell
From there you can select a powershell terminal instead of the usual command prompt
VSCode Change Default Terminal
Here is a detailed guide. Just changing the value of the object, works unless you're running java and other programming languages. It works well even with the Code Runner extension.
Related
I tried to follow the Microsoft Docs instructions to set a keybinding for opening a duplicate tab with the following line { "command": "duplicateTab", "keys": "ctrl+shift+d" }, but, when I press the key combination, it opens a new tab without duplicating the position (the folder where I am) of the current tab. Here's my json file:
"keybindings":
[
...
//This makes a copy of the current tab and opens it.
{ "command": "duplicateTab", "keys": "ctrl+shift+d" }
]
I've written up a longer version of the answer to this over at https://github.com/MicrosoftDocs/terminal/pull/449. To keep it short:
Typically, the "new tab" and "split pane" actions will always open a new tab/pane in whatever the startingDirectory is for that profile. However, on other platforms, it's common for new tabs to automatically use the working directory of the current tab as the starting directory for a new tab. This allows the user to quickly multitask in a single directory.
Unfortunately, on Windows, it's tricky to determine what the current working directory ("CWD") for a process is. Even if we were able to look it up, not all applications actually set their CWD as they navigate. Notably, Windows PowerShell doesn't change its CWD as you cd around the file system! Duplicating the CWD of PowerShell automatically would almost always be wrong.
Fortunately, there's a workaround. Applications can emit a special escape sequence to manually tell the Terminal what the CWD should be.
For example, for cmd.exe:
cmd uses the %PROMPT% environment variable to configure the prompt. You can easily prepend the prompt with the command to set the CWD with the following command:
set PROMPT=$e]9;9;$P$e\%PROMPT%
This will append $e]9;9;$P$e\ to your current prompt. When cmd evaluates this prompt, it'll replace
the $e with the escape character
the $p with the current working directory
This question already has answers here:
How to quickly change shell folder to match the currently open file
(5 answers)
Closed 3 years ago.
In class we had a hotkey for using the terminal with the currently choosen directory. I fixed an issue now with the debugger and everything seems to run smoothly now. Yet, what hotkey fixes this issue?
With VSCode 1.39 (Sept. 2019), no more plugin needed.
You now can "Open new terminals with custom working directories"
There is a new command that allows the creation of terminals with a custom current working directory (cwd):
{
"key": "cmd+shift+c",
"command": "workbench.action.terminal.newWithCwd",
"args": {
"cwd": "${fileDirname}"
}
}
You can create your own keyboard shortcuts to open new terminals in any number of handy working directories.
The cwd value can either be a normal path or a variable.
For a hotkey to quickly set your terminal folder to your current directory, see How to quickly change shell folder to match the currently open file
{
"key": "alt+t",
"command": "workbench.action.terminal.sendSequence",
"args": {"text": "cd '${fileDirname}'\u000D"}
},
This will change your current terminal, not open a new terminal - if you want to do that see the link above as well for the new command recently added to vscode.
Note that on windows, you must use the following instead:
"args": {"text": "cd /d \"${fileDirname}\"\u000D"}
This is because on Windows, the /d parameter must be used with cd to switch drives.
By default, the terminal will open at the folder that is opened in the Explorer. The hotkey for that depends on your operating system, in my case, on macOS, it's ⌃ + `, on Windows I think it's ctrl + j.
If you want to open at a specific folder you can change that behaviour with this setting:
{
"terminal.integrated.cwd": "/home/user"
}
If you want to open at the current file's directory you can install an extension like Terminal Here.
You can change the shortcuts/hotkeys for many actions on Code. For that open the Keyboard Shortcuts editor under File > Preferences > Keyboard Shortcuts and search for Toggle Integrated Terminal.
I looked at this link which talks about changing the default command shell in the integrated terminal of Visual Studio Code. I was able to change it to Git Bash using the below setting in the settings.json file. You can open settings.json file by pressing the Ctrl + , or from File → Preferences → Settings menu:
{
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}
There is a + sign in the integrated terminal with the help of which you can have multiple terminals running parallelly as shown in the screenshot below:
I want to load a Git Bash shell in terminal # 1, Windows PowerShell in terminal # 2, and so on. What is the relevant configuration to achieve it?
No need to keep changing your default terminal setting. Install the Shell Launcher extension, configure it, and then ctrl-shift-t to select which terminal you want to open inside of VS Code.
As of June 17 '2018, things have become really smooth in Visual Studio (VS) Code when it comes to changing the integrated command shell. I'm enlisting all the options here:
Select a different command shell on the go - Name of the command shell is itself a command to switch the current command shell to the target command shell. For example, let's say my integrated command shell is currently showing Bash, and I want to switch to PowerShell. Then type powershell command and press Enter. The command shell will change to PowerShell. Similarly it works for all other types of command shells installed in VS Code.
More instances of command shell - Press Ctrl + Shift + `(back-tick). Every time you press the keyboard shortcut combination, a new instance of the command shell will get added.
Change the configuration of default command shell type - Press F1 in Visual Studio Code and type or select Terminal: Select Default Shell as shown in the snapshot below.
Once selected, then choose the default command shell of your choice to change the settings permanently:
In recent version (1.15.0) you can
change the settings, then run the terminal, you've set
then change the settings again and run the another type of terminal by pressing the + sign
and so on...
You can put this in your settings file, and uncomment which one you need.
// 64-bit cmd if available, otherwise 32-bit
//"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe"
// 64-bit PowerShell if available, otherwise 32-bit
//"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
// Bash on Ubuntu (on Windows)
//"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
Click on Arrow then click something like Select template profile
so then , will Open the search bar automatically, so... change by your choice
Terminal profiles is what you are looking for - https://code.visualstudio.com/docs/terminal/profiles. It didn't exist by the time the question was posted and the only solution by that time was the somewhat limited "terimnal.integrated.terminal.xxx" solution.
Example configuration:
"terminal.integrated.profiles.windows": {
"Cmd": {
"path": "C:\\Windows\\System32\\cmd.exe",
"icon": "terminal-cmd"
},
"GitBash": {
"path": "C:\\Program Files\\Git\\bin\\bash.exe", "icon": "terminal-bash",
"icon": "terminal-bash"
},
"PowerShell": {
"path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
"icon": "terminal-powershell"
},
},
I'm using vscode in Windows 10 as my code editor, and want to make an easy way to launch it with the correct conda env to allow debugging.
Currently I am having to open a command prompt, then activate the conda env, then paste the shortcut to vscode into the prompt to execute. Like so:
cmd
activate env-name
"C:\Program Files (x86)\Microsoft VS Code\Code.exe"
I have tried creating a batch file to wrap these calls, but unfortunately once I call "source activate" to start the conda env, the batch commands after this are not executed as it is considered another instance.
Any tips? Other than writing a vscode extension to handle this (which I'm seriously tempted to do, but it's such a simple problem...)
You might want to run source activate env-name as a task in visual studio.
https://code.visualstudio.com/Docs/editor/tasks
tasks.json
{
"version": "0.1.0",
"command": "cmd",
"isShellCommand": true,
"suppressTaskName": true,
"args": [],
"tasks": [
{
"taskName": "development",
"args": ["source", "activate", "env-name"]
}
]
}
The best option I found is to set the python.venvPath parameter in vscode settings to your anaconda envs folder.
"python.venvPath": "/Users/[...]/Anaconda3/envs"
Then if you bring up the command palette (ctl + shift + P on windows/linux, cmd + shift + P on mac) and type Python: Select Workspace Interpreter all your envs will show up and you can select which env to use.
The python extension will also need to be installed for the Select Workspace Interpreter option.
Note: The Select Workspace Interpreter takes around 10 seconds to come up on my computer using the current version of VSCode. My answer was originally posted here.
Using Conda 4.7.5, I was able to change the Target under the VsCode taskbar shortcut Properties from:
"C:\Users\Paul.siersma\AppData\Local\Programs\Microsoft VS Code\Code.exe"
To:
C:\Users\Paul.siersma\Anaconda3\_conda.exe run -p C:\Users\Paul.siersma\Anaconda3 "C:\Users\Paul.siersma\AppData\Local\Programs\Microsoft VS Code\Code.exe"
This uses the run command (marked experimental) and starts VSCode using the base Conda environment. You could specify another environment by changing the -p flag to the environment location eg -p [..]\Anaconda3\envs\myenv
I want to change the default terminal app used by Visual Studio Code for Mac. I am thinking it is part of preferences or settings json, but unsure.
Here's an example of how to make another terminal the default for VSCode, in this example I've downloaded iTerm2 and copied iTerm2 to Applications.
Code (Menu) > Preferences > User Settings
Edit settings.json "terminal.external.osxExec": "iTerm.app" and "terminal.explorerKind": "external"
Open in Terminal
iTerm is now default terminal launched from VSCode
For those that want to change the default integrated terminal NOT just the external, and add custom themes, show which git branch you are on, and whether or not files need to be staged or committed for example.
Follow these short steps:
Make sure you have these installed:
iTerm2, oh-my-zsh
Install a powerline font (I am using Menlo which is a nice looking and very popular font).
Go here and click on download
Open the file
Click on install font
(Note: without this, vscode integrated terminal will not render themes correctly)
Open the .zshrc file by running this command:
cd ~ ; code .zshrc
Change iTerm's theme to agnoster:
Press ⌘f to open search in the .zshrc file
Type ZSH_THEME
Search until you find the live code, NOT the commented out code :)
Edit the code it so it looks like ZSH_THEME="agnoster"
Save the file
Open vscode settings using shortcut:
⌘,
Inside of vscode settings, you will see two panels. On the right panel paste this:
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.fontFamily": "Menlo for Powerline"
Assuming the settings were empty before, it should now look like this:
{
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.fontFamily": "Menlo for Powerline"
}
Finished! Enjoy your new pimped out terminal
-(Optional customization)-
If you want your prompt to display something other than your username such as a thunder bolt, like in mine or anything you want
Open agnoster theme by runnning this command:
cd ~/.oh-my-zsh/themes/ ; code agnoster.zsh-theme
Open search by pressing:
⌘f
Paste this in search bar:
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER#%m"
To change your what your prompt displays, edit ONLY this part:
$USER#%m
DO NOT CHANGE this part:
prompt_segment black default "%(!.%{%F{yellow}%}.)
In conclusion, the code should now look something like this:
prompt_segment black default "%(!.%{%F{yellow}%}.) Insert here whatever your heart desires"
(Note: Technically you can change everything about your terminal prompt, but for the sake of keeping this short, and simple we only edited the username part)
None of these answers fully worked for me. Here is what I changed to get it to work:
Select the default shell as zsh:
CMD + SHIFT + P to open up the command palette. Then type Terminal: Select Default Shell. You can then select zsh.
Change the terminal to use iTerm
Change the font family to use Powerlevel10k
Result
I recently changed my terminal in VSCode to ozh, its just 1 step and 1 line.
Open Command Palette using View > Command Palette
( or simply Command + Shift + P )
add the following line to the user settings.
"terminal.integrated.shell.osx": "zsh"
well I know it's so late, but you could just change it by running command
Terminal: Select Default Shell
its so much easier
From visual studio code blog:
// 64-bit cmd it available, otherwise 32-bit
"terminal.integrated.shell.windows":"C:\\Windows\\sysnative\\cmd.exe"
// 64-bit PowerShell if available, otherwise 32-bit
"terminal.integrated.shell.windows":"C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
// Bash on Ubuntu (on Windows)
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
Reference: Integrated Terminal
In vscode settings.json add:
"terminal.integrated.profiles.osx": {
"zsh": null
},
No. But you can vote for this feature here: https://visualstudio.uservoice.com/forums/293070-visual-studio-code