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
Related
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,
}
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
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" }
]
}
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"
}
}
What I want to achieve is using zsh in "output" pane whenever I run a Task in VSCode, but it keep using /bin/sh instead.
The "Terminal" pane is using zsh correctly though.
Here's my configurations:
➜ ~ echo $SHELL
/bin/zsh
➜ ~ which zsh
/bin/zsh
tasks.json
{
"version": "0.1.0",
"command": "echo Im $0",
"suppressTaskName": true,
"isShellCommand": {
"executable": "/bin/zsh"
},
"showOutput": "always",
"tasks": [
{
"taskName": "Test",
"args": ["test"]
}
]
}
And the output when I run the Task is:
Im /bin/sh
You could change the settings from menu File -> Preferences -> Settings. Then put the options to use zsh shell.
... another lines
... another lines
"terminal.integrated.shell.linux": "zsh"
The recommended way to do this now is the following:
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "zsh",
"args": []
}
},
"terminal.integrated.defaultProfile.linux": "zsh"
As the other answer presents the deprecated way to do it.
Note that you can customize this profile with arguments if need be :)