integrated (gnome-terminal) zsh vscode \ IDE webstorm - visual-studio-code

Hi all.
I'm having a problem in integrating a customized zsh shell into vscode and webstorm IDE.
By default, both code editors see the path to zsh at zsh, however, vscode writes
'The terminal process "/home/cstrp/zsh" failed to launch (exit code: 1).' and added path to /usr/bin/zsh vscode writes: 'Value is not accepted. Valid values: null, "sh", "bash", "sh (2)", "bash (2)", "JavaScript Debug Terminal".(1)'
config vsCode
"terminal.integrated.profiles.linux": {
"bash": null,
"zsh": {
"path": "zsh",
"args": [
"-l"
]
},
},
// "terminal.integrated.linux": "zsh",
"terminal.integrated.automationProfile.linux": {
"path": "zsh",
},
default shell
my pc

It was only necessary on behalf of the super user to install all the code editors in the right place

Related

home directory is unpreferable location in msys2 shell in integrated teriminal of vscode

I want to use msys2 as a integrated terminal in vscode, so I added this configulation to my user setting.json in vscode.
"terminal.integrated.profiles.windows": {
"MSYS2 UCRT64": {
"path": [
"C:\\msys64\\usr\\bin\\bash.exe",
],
"args": [
"--login",
"-i"
],
"env": {
"MSYSTEM": "UCRT64",
"CHERE_INVOKING": "1",
"MSYS2_PATH_TYPE": "inherit"
}
},
},
"terminal.integrated.defaultProfile.windows": "MSYS2 UCRT64",
And when I open the vscode and toggle terminal window, the msys2 launch, but its start folder is not the same with the one when I launch it from installed location(c/msys64/ucrt64.exe).
shumbow#DESKTOP-STEUAV4 UCRT64 /c/Users/shumbow
$ pwd
/c/Users/shumbow
This is when I launch it from install location.
shumbow#DESKTOP-STEUAV4 UCRT64 ~
$ pwd
/home/shumbow
Could anyone teach me the way I can make these two same?
#HolyBlackCat Removing the CHERE_INVOKING env variable did the trick!(answer by HolyBlackCat). Thanks.

Default directory for zsh (cygwin) terminal is home not working directory VSCode on Windows

I have setup custom profile for zsh via Cygwin in VSCode as below:
"terminal.integrated.profiles.windows": {
"zsh": {
"path": "C:\\cygwin64\\bin\\bash.exe",
"args": ["--login", "-c", "zsh"],
"overrideName": true,
"color": "terminal.ansiRed"
}
},
"terminal.integrated.defaultProfile.windows": "zsh",
But the default directory is /home/ADMIN, not my working directory (repo directory of source code I'm working). Does anyone know how to solve this problem? Thank you in advance.
Try
"terminal.integrated.env.windows": {
"CHERE_INVOKING": "1"
},

VSCode terminal task not using zsh profile

I'm trying to run a task on window load in VSCode where a terminal opens and nvm use && yarn dev is run by default. However, running this shell tasks seems to not load my zsh profile.
The output I get from running my task is:
The terminal process "zsh '-c', 'nvm use && yarn dev'" terminated with exit code: 127.
Terminal will be reused by tasks, press any key to close it.
But if I then manually start a new terminal and run the same command (ie: by pressing plus, opening a new integrated terminal), it will work as intended.
Suspecting that VSCode isn't loading my profile for some reason, I tried adding the following to my task, it resulted in the error /bin/zsh: can't open input file: nvm use && yarn dev The terminal process "zsh '-l', 'nvm use && yarn dev'" terminated with exit code: 127..
// in dev task
"options": {
"shell": {
"executable": "zsh",
"args": ["-l"]
}
},
.vscode/tasks.json
{
"version": "2.0.0",
"presentation": {
"echo": false,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true
},
"tasks": [
{
"label": "Create terminals",
"dependsOn": [
"Dev",
],
// Mark as the default build task so cmd/ctrl+shift+b will create them
"group": {
"kind": "build",
"isDefault": true
},
// Try start the task on folder open
"runOptions": {
"runOn": "folderOpen"
}
},
{
"label": "Dev",
"type": "shell",
"command":
["nvm use && yarn dev"],
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "dev-group"
}
},
]
}
This worked for me-
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "/bin/zsh",
"args": ["-l", "-i"]
}
},
github.com/microsoft/vscode/issues/143061
try adding this to your settings.json
"terminal.integrated.profiles.osx": {
[...]
"zsh": {
"path": "/bin/zsh -l",
"args": [
"-l"
]
},
[...]
},
Note that the important part is
"path": "/bin/zsh -l",
I had the same problem and I found that for some reason VScode does not take into consideration the -l flag passed in args. So you can just include it with path.
If you do not have terminal.integrated.profiles.osx in your settings, you can copy it from the default settings (open the Command Palette and search for 'default settings').
I did not need to do this, but you can make sure that zsh is the default terminal profile for VScode by setting terminal.integrated.defaultProfile.osx to zsh
Try running echo $SHELL from VSCode's integrated terminal. If you're on a Mac or Linux machine, you can compare that output to the output from the terminal app (outside VSCode). It's possible your default shell in VSCode is set incorrectly or using a copy of zsh at another location. If so, set VSCode's default shell through the command palette (Terminal: Select Default Shell).
Also check out your shell's default profile (Terminal: Select Default Profile) from the command palette and make sure it's set to zsh -l... using the -c argument (non-login non-interactive) will prevent ~/.zshrc from being executed, which sounds like what's going on here given your error output.
Finally, confirm your profile is located correctly (at ~/.zshrc) and that both nvm and yarn PATHs are exported. Alternatively, if you're trying to reference yarn locally (if for some reason you only installed it locally), you'll need to run yarn via npx...
You may need to add an automation profile as well
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "/bin/zsh -l",
"args": ["-l"]
}
},
"terminal.integrated.automationProfile.osx": {
"path": "/bin/zsh"
}
macOS 12.6.1 | vscode 1.74.0
I did not manage to do any if it since none of this worked, so I have just removed warning...
"terminal.integrated.showExitAlert": false
Or via GUI
I hope that will not get minus points here...

vscode allow only wsl terminal in a workspace

I have these settings in my workspace:
"terminal.integrated.defaultProfile.windows": "Ubuntu-20.04 (WSL)",
"terminal.integrated.profiles.windows": {
"Ubuntu-20.04 (WSL)": {
"path": [
"C:\\WINDOWS\\System32\\wsl.exe"
],
"args": [],
}
},
I want to either disable all others or set it wsl as default.
I still have all the rest in my list:
When I set wsl as default, its working only when I create a new terminal...
How can I remove all the others and stay only with wsl?
Thanks

GitBash not showing up as a terminal option in Visual Studio Code

I am trying to insert GitBash as an option in Visual Studio Code. My settings look like so:
"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"
},
"GitBash": {
"source": "GitBash",
"path": ["F:\\Code\\Git\\bin\\bash.exe"],
"icon": "terminal-bash"
}
},
"terminal.integrated.defaultProfile.windows": "GitBash"
However, at the last line, the error that Visual Studio Code gave is:
Value is not accepted. Valid values: "PowerShell", "Command Prompt".(1)
The default profile used on Windows. This setting will currently be ignored if either #terminal.integrated.shell.windows# or #terminal.integrated.shellArgs.windows# are set.
I do not understand where I went wrong.
Note: "terminal.integrated.shell.windows" is deprecated as of April 2021.
VS Code version 1.57.1.
Added path of Git, Git\bin, Git\cmd in env. Had "Git Bash" profile with source and path elements. Removed source and kept only the path. When adding defaultProfile as "Git Bash" got "Value is not accepted" error. Restarting VS Code did not help.
Changing "Git Bash" to "GitBash" (space removed) finally worked for me:
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": ["D:\\ProgramFiles\\Git\\bin\\bash.exe"],
"args": []
},
...
}
"terminal.integrated.defaultProfile.windows": "GitBash"
I am not sure if space is actually the problem. Because there is a profile "Command Prompt" with space in its name and recognized!!! To confirm this further, changed "PowerShell" to "Power Shell", and it worked too.
I am not clear how space matters only in the "GitBash" profile.
I believe Visual Studio Code uses your PATH variables to find which profiles are available on your machine. I am guessing you do not have the location of Git Bash set in your PATH. But, that should be fine since you specify the path property in the setting. The issue is you are also setting the source property. According to the description for the terminal.integrated.profiles.windows setting, you can either set the source or the path, not both:
The Windows profiles to present when creating a new terminal via the terminal dropdown. Set to null to exclude them, use the source property to use the default detected configuration. Or, set the path and optional args
Delete the source property, and see if the issue resolves and you can open a git bash terminal in Visual Studio Code.
Also, you may need to restart Visual Studio Code after making these changes. It might be a separate bug, but the terminal.integrated.profiles.windows setting won't detect any new profiles added until you restart.
For anybody using a custom dir for git installation: It does not work with Version: 1.60.2 (user setup)
Win10 User:
Install or just copy git in C:\Program Files
Add Path Variables name: GIT_HOME_2 variable: C:\Program Files\Git
In double click on Path and add "%GIT_HOME_2%\bin"
Open VS Code, you should now see the bash terminal
{
"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"
},
},
"terminal.integrated.env.windows": {
},
"terminal.integrated.defaultProfile.windows": "Git Bash"
}
I have VS Code 1.63.2
Removing the source property or the space in "Git Bash" didn't help. But I found this on their official site and I noticed that the .exe file itself is specified in path:
{
"terminal.integrated.profiles.windows": {
"My PowerShell": {
"path": "pwsh.exe",
"args": ["-noexit", "-file", "${env:APPDATA}PowerShellmy-init-script.ps1"]
}
},
"terminal.integrated.defaultProfile.windows": "My PowerShell"
}
So I tried adding \\bash.exe to the path in the settings and it worked:
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": "D:\\Git\\bin\\bash.exe",
"icon": "terminal-bash"
}
},
"terminal.integrated.defaultProfile.windows": "GitBash"
This works for me when pasted in the settings.json:
{
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": [
"C:\\Program Files (x86)\\Git\\bin\\bash.exe"
]
}
}
}
But only if "GitBash" has no spaces. "Git_Bash" is also fine but not "Git Bash".
Use the syntax below if you want "GitBash" to become the default:
{
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": [
"C:\\Program Files (x86)\\Git\\bin\\bash.exe"
]
}
},
"terminal.integrated.defaultProfile.windows": "GitBash"
}
In VS code go to File -> Preferences -> Settings
Select edit mode in JSON format and set below property value
"terminal.integrated.profiles.windows": {
"Bash": {
"path": "C:\\Git\\bin\\bash.exe"
},
}
Reopen the VS code and check the terminal list and select bash
By configuring profile as bash in the above format it worked finally!!!
{
"terminal.integrated.profiles.windows":{
"GitBash":{
"path":"D:\\projects\\tools\\Git\\bin\\bash.exe"
},
},
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.profiles.linux": {
Changing "Git Bash" to "GitBash" (space removed) worked for me:
I had a similar issue. As Timothy. G pointed out, you can only have "source" or "path", not both. But also, simply restarting VS Code enables the newly created profile.
Here's the one I created to have a conda terminal by default (on windows)
"terminal.integrated.profiles.windows": {
"Conda": {
"path": "C:\\windows\\System32\\cmd.exe",
"args": [
"/K", "C:\\ProgramData\\Anaconda3\\Scripts\\activate.bat C:\\ProgramData\\Anaconda3"
],
"icon": "squirrel"
}
},
"terminal.integrated.defaultProfile.windows": "Conda",
This worked for me:
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.profiles.windows": {
"Git Bash": {
"path": "C:\\ProgramFiles\\Git\\bin\\bash.exe"
},
"PowerShell": {
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
}
}
Remove the brackets in the path worked for me
Open a new terminal by going to Terminal -New Terminal
In the right drop downlink -Select Default Profile
Then select configure Terminal Profile gear icon
Type the name of the profile that need to be created and press Enter
Then it will open the setting page and change the path to your
terminal path
After struggling with this, a simple solution i found, at least in my case where git is not installed in default path, is to make a symbolic link with this command:
mklink /d "C:\Program Files\Git" "D:\Archivos de Programa\Git"
/d stands for symbolic link.
First path is where the link be located.
Second path is where your Git is actually installed.
After restarting VSCode, i was allowed to see Git Bash on terminal list and set it as default.
The solution is to uninstall git and reinstall it in the default location which is (C:\Program Files\Git). All the other hacks failed.
On Windows - Sept 2022
Open VS Code JSON Settings
Open VS Code
'Ctrl + ,' Control key combined with comma at the same time
At the top right corner of VS Code, click on the File icon - with a tooltip of Open Settings (JSON)
Now add this code to your JSON file
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.external.windowsExec": "C:\\Program Files\\Git\\git-bash.exe",
Note: If you installed Git in a different partition on windows, kindly change the drive to its correct letter and not 'C://'
Win11, VS Code 1.71.2
maybe you should try this
failed (Value is not accepted...)
"terminal.integrated.profiles.windows":{
"GitBash": {
"path": "D:\\dev\\Git\\bin\\bash.exe"
},
...
},
"terminal.integrated.defaultProfile.windows": "GitBash",
work
"terminal.integrated.profiles.windows":{
"GitBash": {
"path": "D:/dev/Git/bin/bash.exe"
},
...
},
"terminal.integrated.defaultProfile.windows": "GitBash",
As of February 2023 (version 1.75.0), the following settings should work.
{
"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"
},
"GitBash": {
"path": "${env:homepath}/Software/git/current/bin/bash.exe",
"icon": "terminal-bash"
},
},
"terminal.integrated.defaultProfile.windows": "GitBash",
}
I downloaded/installed the 64-bit Git binaries to a user directory.
Visit Git - Download for Windows
Locate the Portable ("thumbdrive edition") section
Choose architecture e.g. 64-bit ~ https://github.com/git-for-windows/git/releases/download/v2.39.1.windows.1/PortableGit-2.39.1-64-bit.7z.exe
Install Git to your user directory e.g. "Software/Git"
Notes
You do not need to install Git to C:\Program Files\Git
You can use forward-slash / instead of an escaped back-slash \\ in paths
Spaces are not allowed in the profile name/key. Use either "GitBash" or simply "Bash"
If you want to change the "icon" value for your GitBash profile to e.g. Git/GitHub-related icons, you can just use the value "github" or "git-merge". You can use any of VS Code's codicon values as a terminal icon.
See also
DEV - How to set Git Bash as integrated terminal in VSCode in 2021