How can I disable integrated terminal profiles that VS Code defines by default? - visual-studio-code

When I click on new terminal I see all the shells available in my Windows 11 (powershell, ubuntu from WSL, gitbash, etc)
What I need is a configuration to remove / hide / disable the ones I don't use and only leave 1 or 2, that is, from the list, only keep Powershell and Ubuntu, instead of the 5 that appear.
The only settings asociate to terminal I have is:
"terminal.integrated.profiles.windows": {
"pwsh": {
"path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
"args": ["-nologo"]
}
},
Here are the profiles that show up by default on Windows:
I need is a configuration to remove the ones I don't use.
I have been looking for information about this topic but I have not found how to achieve it.
UPDATE:
I solved with this:
"terminal.integrated.profiles.windows": {
"PowerShell": null,
"Git Bash": null,
"Command Prompt": null,
"Ubuntu-20.04 (WSL)": null,
"JavaScript Debug Terminal": null,
"Windows PowerShell": null,
"pwsh": {
"path": "pwsh.exe",
"args": ["-nologo"],
"name": "pwsh"
},
"bash": {
"path": ["C:\\WINDOWS\\System32\\bash.exe"],
"name": "bash"
}
},
"terminal.integrated.defaultProfile.windows": "bash",

It seems that VS Code will always merge in the default-defined terminal profiles to the final list of profile definitions and that you can't stop it from doing that.
What you can do is just redefine them either to null, or set those fields to nothing.
For default profiles that use the "path" field, it will not show a profile option with "path" set to an empty array, or a path to something that doesn't exist.
For default profiles that support and use the "source" field instead of the "path" field, set the "source" field to null.
You can find the list of default terminal profile definitions in the default settings JSON file (use the Preferences: Open Default Settings (JSON), and then use the editor search feature to search terminal.integrated.profiles.). Then just copy and paste it into your user or workspace settings.json file and adjust the values as described above.
Here's an example for my own Windows machine:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": null
},
"Command Prompt": {
"path": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": null
},
"Ubuntu-20.04 (WSL)": {
"path": []
},
}
The other way to do it is this:
"terminal.integrated.profiles.windows": {
"PowerShell": null,
"Command Prompt": null,
"Git Bash": null,
"Ubuntu-20.04 (WSL)": null,
"JavaScript Debug Terminal": null,
}

Related

MSYS2 MinGW x64 shell in Visual Studio Code opens up in new window

I want to integrate MSYS2 MinGW x64 shell as a terminal in Visual Studio Code.
I have followed these instructions here. I can now launch a MSYS2 MinGW x64 shell from inside Visual Studio, but it pops up in a new window.
But I want to have it under the editor pane.
Here is my settings.json file:
{
"workbench.colorTheme": "Default Dark+",
"codetogether.userName": "Florian",
"git.autofetch": true,
"codetogether.allowUnauthorizedCerts": true,
"haskell.manageHLS": "GHCup",
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
},
"MSYS2 MinGW x64": {
"path": "D:\\Software\\MSYS2\\msys2_shell.cmd",
"args": []
}
}
}
What do I need to change here?
I managed to solve the problem, by replacing
"MSYS2 MinGW x64": {
"path": "D:\\Software\\MSYS2\\msys2_shell.cmd",
"args": []
}
with
"MSYS2 MinGW x64": {
"path": "D:\\Software\\MSYS2\\usr\\bin\\bash.exe",
"args": []
}
in my settings.json file.

VSCode setting zsh terminal as integrated profile does not work

I am working in a remote ssh server, and before the July 2022 update my integrated terminal was working fine. After the update however, I find that it no longer works, but specifically only if I set it to zsh.
I have set the following settings up:
{
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash"
},
"zsh": {
"path": "/bin/zsh"
},
"zsh (2)": {
"path": "/usr/bin/zsh"
},
"zsh (3)": {
"path": "zsh"
},
"fish": {
"path": "fish"
},
"tmux": {
"path": "tmux",
"icon": "terminal-tmux"
},
"pwsh": {
"path": "pwsh",
"icon": "terminal-powershell"
}
},
"terminal.integrated.defaultProfile.linux": "zsh",
And all zsh profiles do not work. It is only zsh that does not work; both bash and tmux (which opens up a zsh shell) work. (I did which zsh to confirm the paths, but I wanted to cover all bases, thus the three profiles).
The integrated terminal works in my local machine (which also runs zsh). I'm not sure what else to check, any help is appreciated.
Currently, my workaround is to set up /bin/zsh at the end of my .bashrc and set bash as my default, but I'd rather not do that in the long run.
EDIT:
Here is a picture of my terminal when I set the default to any of the zsh profiles:
Image of terminal

The new way to configure default shell and argument commands in VSCode?

Few days ago I assume Microsoft released a new update for VSCode and when I came to build my esp idf project it didn't work because it relies on a command to run from the terminal before it's "special" project build command is executed and I came to the conclusion that the following setting that allowed that automatically was in file main.code.workspace in "settings" were:
"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"C:/Coding/ESP32/esp-idf/export.bat"
],
and the error is as follows:
This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile in #terminal.integrated.profiles.osx# and setting its profile name as the default in #terminal.integrated.defaultProfile.osx#. This will currently take priority over the new profiles settings but that will change in the future.
What is the new way to configure the default terminal at startup and run this command?
In the settings.json file we need to have the following
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
},
And set the default terminal by adding
"terminal.integrated.defaultProfile.windows": "Command Prompt",
We can achieve this by pressing Ctrl + Shift + P and searching for Terminal: Select Default Profile and selecting the required shell.
However, although deprecated the setting you have currently should work for now.
I have solved this by
1)Add Git/bin to the path in env variables
2)Restart VSC and add the following in settings.json
"terminal.integrated.profiles.windows": {
"PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" },
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"icon": "terminal-cmd"
},
"GitBash": {
"path": ["F:\\Program files\\Git\\bin\\bash.exe"],
"icon": "terminal-bash"
},
},
"terminal.integrated.defaultProfile.windows": "GitBash",
just replace 'your path of git bash' in path for "GitBash"
3)Remove old settings
for me it was
"terminal.integrated.shell.windows": "F:\\Program files\\Git\\bin\\bash.exe"
4)Save settings, Close terminal of VSC by pressing delete, restart VSC
Hope this works!
I recently upgraded to VSCode 1.60 on windows and having similar problem
I added the above mentioned "GitBash" option to profiles but when I tried to use it like this:
"terminal.integrated.defaultProfile.windows": "GitBash",
VSCode complained that "GitBash" is not a valid value:
Value is not accepted. Valid values: "PowerShell", "Command Prompt", "JavaScript Debug Terminal".
So instead I updated the "Command Prompt" profile to point to my git bash and this WORKED
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"C:\\<PATH TO MY bash.exe>",
],
"args": [],
"icon": "terminal-bash"
}
},
"terminal.integrated.defaultProfile.windows": "Command Prompt",
I had the same issue with VS Code v1.60.1 so I downgraded it to v1.59.1 (https://code.visualstudio.com/updates/v1_59) worked fine and also disable auto-update

In VSCode, settings.json, error: "Draft 2019-09 schemas are not yet fully supported. (768)"

My goal is to configure my PowerShell Terminal prompt per Hanselman's instructions here:
https://www.hanselman.com/blog/how-to-make-a-pretty-prompt-in-windows-terminal-with-powerline-nerd-fonts-cascadia-code-wsl-and-ohmyposh
It seems I was able to execute the provided instructions. The prompt is rendering as I'd expect in Windows Terminal:
windows terminal
But not in the VSCode terminal:
vscode terminal
VSCode raised this "problem":
vscode schema problem
My VSCode settings.json text is here:
// This file was initially generated by Windows Terminal 1.3.2651.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "***",
// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings
// If enabled, selections are automatically copied to your clipboard.
"copyOnSelect": false,
// If enabled, formatted data is also copied to your clipboard
"copyFormatting": false,
// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
"guid": "***",
"hidden": false,
"name": "PowerShell Core",
"source": "Windows.Terminal.PowershellCore",
"fontFace": "Cascadia Code PL",
"terminal.integrated.fontFamily": "Cascadia Code PL"
},
"list":
[
{
"guid": "***",
"hidden": false,
"name": "PowerShell Core",
"source": "Windows.Terminal.PowershellCore"
},
{
"guid": "***",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "***",
"name": "Command Prompt",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "***",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"guid": "***",
"hidden": false,
"name": "PowerShell Core",
"source": "Windows.Terminal.PowershellCore"
}
]
},
// Add custom color schemes to this array.
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
"schemes": [],
// Add custom actions and keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
"actions":
[
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
{ "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
{ "command": "paste", "keys": "ctrl+v" },
// Press Ctrl+Shift+F to open the search box
{ "command": "find", "keys": "ctrl+shift+f" },
// Press Alt+Shift+D to open a new pane.
// - "split": "auto" makes this pane open in the direction that provides the most surface area.
// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
// To learn more about panes, visit https://aka.ms/terminal-panes
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
]
}

Is there a VS Code shortcut for creating a new file from selected or clipboard code?

I work with large html files that I would like to fragment into separate files. The process of doing this is quite tedious as it requires copying the code, creating a new file, pasting it in the new file, and then selecting a folder and a new name to save it under.
Is there a built-in shortcut, macro or extension for VS Code for making this easier?
Just a note for others that since this is an html file, the new refactor Move to a new file is not available. It does what you want and will work in many other languages, but not html. You can access it by selecting the text to move and in the context menu choose Refactor.. - it may even add import statements to the old file if supported.
Here is a macro which does what you want. I am using the macro extension multi-command but there are others.
In settings.json:
"multiCommand.commands": [
{
"command": "multiCommand.newFileWithContent",
"sequence": [
// choose which one you want
"editor.action.clipboardCutAction",
// "editor.action.clipboardCopyAction",
"workbench.action.files.newUntitledFile",
"editor.action.clipboardPasteAction",
// prompt for save immediately?
"workbench.action.files.saveAs",
]
},
Then trigger it either through the command palette (search for "multi") or with a keybinding (keybindings.json):
{
"key": "strl+alt+b", // your keybinding choice
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.newFileWithContent" }
},
I don't know how to automate the "selecting a folder and a new name to save it under" part of your question. I think you are still going to have to do that manually, but there is some handy "intellisense" for that in the "saveAs" dialog.
Update in 2020
After I came up with this answer, see in vscode how can I quickly generate a new file with datetime in the name?
I thought there might be a better way to handle creating the file with a task and prompting for a folder and filename in one go. You lose the saveAs intellisense on your folder structure, but it is a pretty good technique to know in any case. And a macro isn't needed. In a bash shell:
{
"version": "2.0.0",
"tasks": [
{
"label": "newFile",
// assuming your folder name isn't static
"command": "echo '${selectedText}' > ${input:folderName}/${input:fileName}.html",
"type": "shell",
"problemMatcher": [],
"presentation": { // terminal handling which you may not care about and could delete
"echo": false,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"promptOnClose": false
}
],
"inputs": [
{
"type": "promptString",
"id": "folderName",
"description": "Complete my folder name.",
"default": "folder"
},
{
"type": "promptString",
"id": "fileName",
"description": "Complete my file name.",
"default": "new file name"
}
]
}
Some keybinding to run that task (or just run it from the command palette Run Task command):
{
"key": "alt+r", // whatever you choose
"command": "workbench.action.tasks.runTask",
"args": "newFile"
},
That's it, select your task, and run the task Alt+R.