How to Integrate babun shell in VS code - visual-studio-code

I have tried changing the settings for "terminal.integrated.shell.windows" to babun mintty location. But the babun shell window opens separately and doesn't integrate with the VS code. Anyone knows how to achieve this?

After trying for 2 hours finally made it work.
Before reading my way of doing this, you might want to got through this issue first.
By default babun is installed in C:\Users\13000\.babun\. So we can configure it by overriding user setting in VS Code as:
"terminal.integrated.shell.windows": "C:\\Users\\YOURUSERNAME\\.babun\\cygwin\\bin\\zsh.exe",
After saving , reload the window and you are done.
You will get something like :
Hope this helps!

I was searching for any solution for this issue before and I could not find any. But I was curious how Babun itself run the command "Open Babun here" from right-click menu and noticed it runs this command:
C:\Users\YOURUSER\.babun\cygwin\bin\mintty.exe /bin/env CHERE_INVOKING=1 /bin/zsh.exe
I've tried setting mintty.exe as shell and using leading commands as shell arguments, but this method opens an external terminal. I've noticed this behavior is because using mintty.exe, so I replaced mintty.exe with env.exe itself. At last, these are the settings:
"terminal.integrated.shell.windows": "C:\\Users\\YOURUSER\\.babun\\cygwin\\bin\\env.exe",
"terminal.integrated.shellArgs.windows": [
"CHERE_INVOKING=1",
"/bin/zsh.exe"
]
Edit: This might not completely relate to this question, but because of having the similarity, I think it might worth mentioning.
During my search for a solution, I've seen many other questions about the same issue for integrating Atom's PlatformIO IDE Terminal package or JetBrain's IDEs with Babun's zsh.
In the case of Atom, setting the Shell Override to C:\Users\YOURUSER\.babun\cygwin\bin\env.exe and Shell Arguments to CHERE_INVOKING=1 /bin/zsh.exe opens zsh.exe as an integrated terminal in the project directory.
In the case of JetBrain, I've used WebStrom and this works:
cmd.exe "/k C:\Users\ehsan\.babun\cygwin\bin\env.exe CHERE_INVOKING=1 /bin/zsh.exe"

Just complementing the correct answer that Pramesh Bajracharya gave above, you can override user settings in VS Code opening the VS Code and going in:
File->Preferences->Settings
And then paste in the field shown in your right side (WORKSPACE SETTINGS):
{
"terminal.integrated.shell.windows": "C:\\Users\\YOURUSER\\.babun\\cygwin\\bin\\zsh.exe"
}
More information can be found in https://code.visualstudio.com/docs/editor/integrated-terminal
Thanks Pramesh Bajracharya!

Related

VS Code Not Running Anything - No such file or directory

My VS Code
My VSCode for Mac won't run even simple Python commands. For more context my Python Terminal execute in file dir setting is turned on. I don't know what the problem is, the play button or right clicking and selecting run code also doesn't do anything.
I've already ensured I have the proper VSCode installed for Mac. Please help :(
try to edit your settings.json file like this :
"terminal.explorerKind": "external",
"terminal.integrated.defaultProfile.windows": "Command Prompt"
learn more about using python in VS Code

Can't open VSCode from command-line WSL ZSH

So I decided to quit dual-boot and start using WSL. I'm having a problem and really can figure out how to fix it.
I simply can't open VSCode using the code command from the terminal when using an external terminal. When using the integrated, a command like "code ." works just fine.
Anyone knows how to fix it? It was working good a few steps of setup ago, but I lost track and don't exactly when that happened. I'm currently using HyperJS as terminal and my integrated terminal is already running zsh and it works when the VSCode is connected to WSL and when it isn't aswell.
Anyway, hoping for a fix, 'cause I'm really lost.
Thanks!
It's fixed and it was an easy fix, but it took long for me to realize that all I had to do was one step.
Here's the thing: the command "code" on the integrated terminal was working like a charm because the VSCode itself was running as administrator on Windows.
My Hyper wasn't running as administrator, so all I did was:
Right-click on HyperJS icon and go to the properties of the application
Switch to "Compatibility" tab
Check the "Run as administrator"
It's working without a problem now. Took me a while to realize that, but it's all good now.

No output when running Python 3 in VScode

I'm using Python 3.8 on VScode, but I can't seem to get the program to write anything in output, even with simple commands like: print("Hello world!"). It shows up in the terminal well enough, so the code shouldn't be the problem. Do i need to fix anything in the setting to make it show the output?
1: Picture of terminal:
Please could you check your user settings.json and workspace settings.json for the existence of a setting for terminal.integrated.shell.*.
I believe you may have changed the shell to use command prompt instead of powershell.
Also, please could you provide some screenshots of the terminal
And any errors logged in the console widows (go to Help->Toggle Developer Tools)

VS Code Terminal Not Allowing Typing

My VS code terminal was working fine, until one day when I tried to work on a project, that was still open in VS code, my terminal didn't allow me to type any commands. I couldn't type anything. This is the screen that I get.
Okay, for those of you struggling with the same problem, I've managed to solve it by clicking on the drop-down menu that says powershell and changing it to cmd.
this happened to me and simply
close vs code
right click on it
run as administrator
open the terminal and it will work
this problem happened when I changed the default path of CMD
For me, I tried using Powershell/CMD/Bash and I was having errors/blank terminal. I found typing echo hello and pressing CTRL + C made it appear. So in fact, everything was working, my terminal was just blank/glitched out, but was really accepting input.
I had a similar issue when running ionic serve command which runs the development server on the localhost. I paid attention after executing the command above, and it said:
Use Ctrl+C to quit this process
Pressing Ctrl+C then displays:
Terminate batch job (Y/N)?
Type Y or y
then the command prompt is shown again!
Here is a sample terminal window - trimmed for brevity:
For who has this problem using React. This happens when you start a live version using npm start. The terminal that handles the live version of the app cannot be used for anything else.
So to continue using the terminal you need to open a new terminal to use in parallel. To do so just click on the plus icon in the top right corner of the terminal panel then choose the "Power Shell" option. This will open a new terminal without restarting visual studio.
In Mac, when working with Python, this helped me: instead of clicking on the "Run Code" option, click on "Run Python file", in the right corner.
For Ubuntu users this is solved by this solution:
File -> Preferences -> Setting -> Features -> Terminal -> Inherit Env
I found two vscode on my desktop, I opened the other one and it worked. Looks like I updated it but the older one didn't disappear.
If typing Ctrl+C can help to get out of this frozen state, that will be easier to do with VSCode 1.64 (Jan. 2022)
The terminal can type the answer for you.
Terminal -- Auto-reply
The terminal is now able to automatically reply when a specific sequences of characters is received.
A good example of where this is useful, which is also the only default case, is the Windows batch script message Terminate batch job (Y/N)? after hitting Ctrl+C when running a batch script.
This typically just ends up causing problems for the user.
The terminal will now automatically reply with Y and enter (\r) which makes Ctrl+C in Windows feel much better.
Pressing Ctrl+C will immediately reply to the question and return to the prompt:
Theme: Sapphire
The feature was made generically so you can setup custom replies for other thing, just be careful when doing this as you are sending text to the process automatically.
For example you could use it to automatically update Oh My Zsh when prompted:
"terminal.integrated.autoReplies": {
"[Oh My Zsh] Would you like to check for updates? [Y/n]": "Y\r"
}
If you use Clink and enable their similar feature, you can disable it in Clink or in VS Code by setting the reply to null to avoid the two features conflicting with each other:
"terminal.integrated.autoReplies": {
"Terminate batch job (Y/N)": null
}
Go to terminal, preferences, settings.
Check "run code in terminal"
Restart VS.
I changed from bash to powershell in terminal first but the command prompt still not shown.
Then I navigate to File -> Perferences -> Settings and it starts working (command prompt shown)
This seems to just be a display problem. It happened to me when I changed my display settings for desktop icon and app scaling settings.
I managed to fix the problem by simply restarting my computer and re-opening VS code
I had the same problem ... In my case just run vs-code as administrator and works

zsh doesn't work in the vscode built-in terminal

echo $SHELL
logged: /bin/zsh
why the built-in shell is still bash
what should I config vscode the to make the zsh works in the built-in terminal?
For those who are using MAC
Launch Visual Studio Code and go to Settings.
In Settings, click on the features dropdown and then on Terminal
Click on edit in settings.json (the icon at the top right) and add this line of code to the user settings json file:
"terminal.integrated.shell.osx": "/bin/zsh"
then you must close that terminal with the trash icon.
that's it, now if you open another terminal you should see the ZSH terminal.
#Ale's answer is no longer valid! It should be used the following instead:
"terminal.integrated.defaultProfile.osx": "zsh"
You can set the terminal.integrated.shell.linux property as described here. If you need to pass arguments to zsh, use the terminal.integrated.shellArgs.linux property.
#ccoutinho updated Ale DC's answer to the proper path:
"terminal.integrated.defaultProfile.osx": "zsh"
But I also needed Ale DC's extra tip to trash the currently displayed embedded terminal (clicking the trash icon at the top right of the terminal tab). Otherwise I had one instance showing zsh and another refused to show zsh and it was driving me crazy.
Hope that helps.