The new way to configure default shell and argument commands in VSCode? - visual-studio-code

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

Related

How can I disable integrated terminal profiles that VS Code defines by default?

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,
}

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.

VS Code split terminal issues with Powershell only

hope this finds you well. I feel like my issue something simple but googling and searching through here I couldn't find someone with this exact issue. It's something small but my ocd is killing me about it. In VS Code anytime I try to "split" my powershell terminal it gives me this issue
My default terminal is Powershell and this only happens if the first terminal instance is Powershell. So for example, I can split a terminal between git bash and powershell if I select the git bash terminal and split it like so.
I'm pretty sure the issue is the double quotes around my path. ""C:\Users\Austin Lee"" does not exist. I tried switching the starting directory with terminal.integrated.cwd = "" in my settings.json based on an answer I had seen somewhere, but that didn't fix it. I'm willing to uninstall and reinstall VS Code but I'm not sure this would fix the issue. If anyone has any suggestions please let me know.
also adding my settings.json from VS code. If anything looks weird please let me know haha. if anyone needs any more info I can provide whatever you need, and I really appreciate the input. Also don't know if it matters but I am using oh my posh on powershell for theming and terminal icons but I could split a terminal before, so I'm not really sure when this problem started or if an extension is messing it up, but I disabled all installed extensions and the issue is still happening
"editor.defaultFormatter": "esbenp.prettier-vscode",
"security.workspace.trust.untrustedFiles": "open",
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.fontFamily": "Hasklug Nerd Font",
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"liveServer.settings.donotVerifyTags": true,
"git.autofetch": true,
"editor.formatOnSave": false,
"workbench.iconTheme": "vscode-icons",
"prettier.semi": false,
"typescript.preferences.quoteStyle": "double",
"editor.bracketPairColorization.enabled": true,
"workbench.colorTheme": "Dracula",
"remote.SSH.remotePlatform": {
"172.105.135.48": "linux"
},
"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"
},
"Ubuntu (WSL)": {
"path": "C:\\WINDOWS\\System32\\wsl.exe",
"args": [
"-d",
"Ubuntu"
]
},
"Windows PowerShell": {
"path": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
}
},
"files.exclude": {
"**/bin": true,
"**/obj": true
},
"explorer.compactFolders": false,
"[csharp]": {
"editor.defaultFormatter": "ms-dotnettools.csharp"
},
"vsicons.dontShowNewVersionMessage": true,
"editor.stickyScroll.enabled": true
}```

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

Automatically Execute a command when opening a new Integrated Terminal in VSCode IDE

Can VSCode IDE do this?
Execute a command such as running a batch file or powershell script automatically when a new Integrated Terminal is opened?
Yes, you can use the "terminal.integrated.shellArgs" setting to pass arguments to the shell. For instance, the following will print Hello World when opening a new Terminal instance:
"terminal.integrated.shellArgs.windows": [
"-NoExit", "-Command", "Write-Host Hello World"
]
The previous answer was deprecated although it will still work but with a warning. The new way to do it in VS Code is to add this section to your settings.json. Here I configured my PowerShell to automatically import a module posh-git that prettifies my command prompt for git. :)
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell",
"args": [
"-NoExit", "-Command", "Import-Module posh-git"
]
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
}