VSCode + Cmder integration - strange issue - visual-studio-code

could you tell me why while I integrate the vscode and cmder, like that:
"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.shellArgs.windows": ["/k", "%CMDER_ROOT%\\vendor\\init.bat"]
and use mini_cmder version, everything is working fine. But if I do it the same with full version of cmder, the "Open in terminal" option from contextual menu doesen't work. Anybody know how to resolve that?
Best Regards,
crova

Yes, to use the Cmder shell in VS Code, you need to create a vscode.bat file in your cmder path with the following contents:
#echo off
SET CurrentWorkingDirectory=%CD%
SET CMDER_ROOT=C:\cmder (your path to cmder)
CALL "%CMDER_ROOT%\vendor\init.bat"
CD /D %CurrentWorkingDirectory%
then in your VS Code user settings, add the following to your settings.json file:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/K", "C:\\cmder\\vscode.bat"]

Related

Visual Studio Code terminal error: The filename, directory name, or volume label syntax is incorrect

I have this issue in microsoft visual studio code, whenever I open the terminal the first message I get is The filename, directory name, or volume label syntax is incorrect. The terminal works fine.. just it bugs me to see see this error message whenever I open the terminal.. how do I fix it?
I Installed Cmder as my default visual studio code terminal, maybe there is something related to this error?
thanks in advance
I am not sure how you have installed cmder as the integrated terminal in vscode but in settings.json you could try pointing the terminal.integrated.shell.windows to cmd.exe and the terminal.integrated.shellArgs.windows to what makes cmd.exe be (act like) cmder which is cmder's init.bat file. So in your vscode settings.json add or modify the below lines to point to your cmd.exe and cmder init.bat respectivley.
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [ "/k", "C:\\cmder\\vendor\\init.bat"],
I got the same problum but it got fixed by following this steps
go to setting and search json
click on launch -(Edit in setting.json)
now replace the line "terminal.integrated.shell.windows":(path as showing) line to
"terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe",
"terminal.integrated.shellArgs.windows": [ "/k", "C:\cmder\vendor\init.bat"],
save the program. Done!

Launch Windows Terminal from VSCode?

I'm trying to launch the new Windows Terminal through VSCode like I have with other terminal emulators.
Previously I've used the following setting in the VSCode JSON file settings.json to launch Cmder through VSCode with ctrl+C
"terminal.external.windowsExec": "C:\\Program Files\\cmder\\Cmder.exe",
However, trying the same with the directory of the Windows Terminal directory has been unsuccessful.
"terminal.external.windowsExec": "C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminal_1.0.1401.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe",
I thought that the executable was wt.exe, so if I'm correct, in your settings.json, you should be using:
"terminal.external.windowsExec": "C:\\Users\\skillcap\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe",
(remember to change the user name as required).
As a side note, the executable should also have been added to your %PATH%, so you should be able to generally start it using just wt, (with an unmodified %PATHEXT% variable).

How do I get around the verified bug in Windows 1903 and launch the VSCode integrated terminal?

I just did a fresh install of Windows 10 Pro version 1903 build 18362.116 and Visual Studio Code. Now the integrated terminal only launches externally.
Pressing Ctrl + ~ results in this.
What am I missing? How do I get it to open integrated again?
EDIT
After working with VSCode team it is a verified bug. See the Github issue here. I posted the workaround as an answer here.
OK, worked through this one in VSCode repo issues.
For now, until it's fixed, turn off ConPTY integration in the User Settings.
💥💥💥
The issue now says use legacy console. To change the setting open a cmd prompt. Right click the title to bring up properties.
Then Uncheck 'Use legacy console'
To change the integrated terminal on Windows, you just need to change the terminal.integrated.shell.windows line:
Open VS User Settings (Preferences > User Settings). This will open two side-by-side documents.
Check if "terminal.integrated.shell.windows" has value "C:\\Bin\\Cmder\\Cmder.exe" setting to the User Settings document on the right.
Remove this line.
Ctrl + ~ will now open integrated terminal of VSCode.
If the above solution doesn't work then can you try below values and check if it works for you:
// Command Prompt
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
// PowerShell
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\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\\System32\\bash.exe"
From the Command Palette (Ctrl+Shift+P), use the View: Toggle Integrated Terminal command.
Try custom shortcut:
[
{
"key": "ctrl+`",
"command": "workbench.action.terminal.toggleTerminal"
}
]
Had this problem fixed. Found the solution from the VS Code support.
for error:
Terminal exits with code 3221225786 (or similar)#
"This can happen when you have legacy console mode enabled in conhost's properties. To change this, open cmd.exe from the start menu, right-click the title bar, go to Properties and under the Options tab, uncheck Use legacy console."
source: VS Code docs

Cmder integration in VS Code with PowerShell not working as expected

I'm trying to use Cmder in VS Code for PowerShell instead of powershell.exe. I followed the official instructions (here) on the cmder GitHub. Now, when I restart VS Code a terminal will be launched. Looks like this:
It's name is 'powershell' and it looks like Cmder but doesn't behave like it.
Perhaps I'm expecting something that is not designed to work but I was expecting 'CTRL+ Backspace' to delete words to the left. Instead I'm getting '^W':
Moreover, as soon as I open a .ps1 file a new terminal gets launched which is named 'PowerShell Integrated Console':
The behaviour of this terminal is the same as the 'powershell' one.
Here's my settings related to the integrated terminal and PowerShell in the settings.json:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"terminal.integrated.shellArgs.windows": [
"-ExecutionPolicy",
"Bypass",
"-NoLogo",
"-NoProfile",
"-NoExit",
"-Command",
". 'C:\\Users\\fhe\\[REMOVED]\\Apps\\cmder_mini\\vendor\\profile.ps1'"
],
"terminal.integrated.rendererType": "auto",
"terminal.integrated.scrollback": 10000,
"powershell.scriptAnalysis.enable": true,
"powershell.integratedConsole.focusConsoleOnExecute": false,
"powershell.enableProfileLoading": true,
I notice that if I change it back to what the official guide suggests under the 'Run Cmder as the VS Code terminal' (here) I will get the expected behaviour when using CTRL+Backspace.
So my questions are:
Is Cmder integration in VS Code designed to provide the CTRL+Backspace functionality for PowerShell?
If so, what might I have configured incorrectly?
Thanks.

How to integrate Cmder properly in VS Code?

I would like to integrate Cmder shell into my VS Code configuration.
I'm using VS Code 64bit on Windows, and I tried to modify my settings.json file as follows, to make Cmder work as the integrated terminal:
"terminal.integrated.shell.windows": "C:\\Program Files\\Cmder\\Cmder.exe",
I restarted my VS Code and tried to open the terminal.
At first, this error message box showed up:
Failed to copy ConEmu.xml file to backup location!
Restart Cmder as administrator.
So, I launched VS Code as administrator, which made the error message disappear; however, I noticed that VS Code opens Cmder in another separate window instead of in the terminal.
How can I run Cmder shell inside VS Code terminal?
P.S. Could this note in vs code documentation be the solution?
Tip: The integrated terminal shell is running with the permissions of VS Code. If you need to run a shell command with elevated (administrator) or different permissions, you can use platform utilities such as runas.exe within a terminal."
from: https://code.visualstudio.com/docs/editor/integrated-terminal
There is a mistake in your configuration file, the following is not valid:
"terminal.integrated.shell.windows": "C:\\Program Files\\Cmder\\Cmder.exe"
You should not be calling Cmder.exe from the VS Code, instead, you should use init.bat (from the instructions below) to integrate Cmder in VS Code.
Your issue has been already explained here over the Cmder repository.
Making Cmder work in VS Code
Make sure you're on the latest release of Cmder – download latest here
Open the settings.json configuration file, by pressing Ctrl + , (Control-Comma) to access the preferences, then click on the Edit in settings.json link
VS Code documentation explains the process in this link:
Can I use Cmder's shell with the terminal on Windows?
Yes, to use the Cmder shell in VS Code, you need to add the following settings to your settings.json file:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/K", "C:\\cmder\\vendor\\init.bat"]
BTW, You need to replace C:\\cmder with your own installation path.
Tip: replace single backslashes (\) with double backslashes (\\).
Make sure you read the notice at the official Cmder wiki:
👉 Please note the use of cmd.exe instead of cmder.exe.
Tip: refer to here on notes about handling spaces in your path.
TL;DR: It's not recommended by the Cmder team, but you may use ^ character before spaces to handle the paths.
You don't need to restart VS Code to make this work.
Hit Ctrl + ` (Control-Tilde) to open Cmder in VS Code terminal!
You may refer to my answer here for a complete explanation of how this works.
Related
There are similar issues over the VS Code repo and here on Cmder repo as well.
Cmder 1.3.12 introduced a vscode_init.cmd script which allows VS Code tasks to work correctly with Cmder.
The documentation in VS Code, referred to in the answer above, is out of date if you're using a version of Cmder greater than 1.3.11.
The Cmder GitHub repository now has extensive documentation on how to achieve integration between Cmder and VS Code. At the time of writing this message, it is more accurate than the VS Code documentation.
This worked for me on June 22nd 2021; add these lines to the settings.json file in your user settings (for me « C:\Users\ianla\AppData\Roaming\Code\User\settings.json »):
"terminal.integrated.profiles.windows": {
"cmder": {
"path": "C:\\WINDOWS\\System32\\cmd.exe",
"args": ["/K", "C:\\Users\\ianla\\cmder\\vendor\\bin\\vscode_init.cmd"]
}
},
"terminal.integrated.defaultProfile.windows": "cmder",
... of course, you'll need to change my « C:\Users\ianla\ » with your instalation "cmder" instalation path.
See here for more info
The following is that worked for me (version of Cmder greater than 1.3.11):
Paste \cmder directory into C:\tools
Paste in .vscode\settings.json :
"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.env.windows": {
"CMDER_ROOT": "C:\\tools\\cmder"
},
"terminal.integrated.shellArgs.windows": [
"/k",
"%CMDER_ROOT%\\vendor\\bin\\vscode_init.cmd"
],
.. and enjoy!