Debugging new VS Code CLI flag in devcontainer - visual-studio-code

I've forked VSCode on Github to try to add a tiny little feature I think would be useful, which adds a new CLI flag to code, to be used inside the VSCode terminal (like code - for stdin). I added the code, wrote tests, and now I want to try out the feature.
I'm developing inside the built-in devcontainer, so I just launched an instance of VSCode from within VSCode, connected to the devcontainer via VNC and tried to use my flag inside the VSCode-OSS terminal. However, I get an error saying "Command is only available in WSL or inside a Visual Studio Code terminal"
According to server.cli.ts, this means that the env variables VSCODE_IPC_HOOK_CLI and VSCODE_CLIENT_COMMAND aren't set, but I don't know who should be setting them, or if I need to launch VSCode in a different way for debugging.
Has anyone using the VSCode DevContainer to write additional CLI flags and knows how to debug them?

Related

Stop automatic `conda activate` when opening a terminal in VS Code

VS Code has started running conda activate every time I open a terminal in VSCode, be it PowerShell, WSL, or CMD.
I never set this up intentionally so have no idea why it does this or how to disable it. I've looked at all my settings in VS Code and cannot find anything.
How do I stop VS Code from running conda activate when a new terminal is opened?
Try putting the following in your settings.json file:
"python.terminal.activateEnvironment": false
You're getting this behaviour because the default value of that setting is true if not specified.
For more info, see VS Code's docs on Using Python environments in VS Code- in particular, the Working with Python interpreters
section, and the Environments and Terminal windows
section.
Quoting from that page:
Tip: To prevent automatic activation of a selected environment, add "python.terminal.activateEnvironment": false to your settings.json file (it can be placed anywhere as a sibling to the existing settings).
Reading the changelog, this setting was added in version 2018.9.0 of the Python extension for VS Code. The PR that added it was #1387.

Change terminal used by Code-Runner extension in VS Code to cmd while workspace default integrated terminal is powershell?

Is there a setting in VS Code for the Code Runner extension that lets you run in a shell that's different than the workspace's default shell?
For context, my default integrated terminal is powershell. I have the code-runner.runInTerminal setting set (see, e.g., here), and whenever I run python using the extension, it creates a new "Code" powershell integrated terminal (unless one already exists), activates my selected python environment, and runs the code. However, when it tries to activate the environment, I get this popup:
So, I'd like to change the shell that Code Runner uses to cmd, BUT I want to keep using powershell as my default integrated terminal for the workspace.
Changing my workspace's default shell to cmd isn't an option, and neither is changing to a third shell like WSL. This issue indicates to me that the environment activation isn't getting fixed in powershell anytime soon. For now, I've done what the issue suggests and have just stopped Code Runner from activating a new environment in the terminals it creates (set python.terminal.activateEnvironment to false), but I'm worried now I won't be able to have Code Runner use any other python environments than the default one. What can I do?

Is there a way to open a file in VS Code from the integrated terminal/codespace?

The integrated terminal in VS code means that you can run builds, scripts and other commands and see the results as is. Sometimes though they produce output files that you'd like to view in an editor, like a logfile or exception trace.
Is there a way of running a built-in command in the terminal to say 'please open this file in vscode', specifically in a codespace? On macOS, you might use 'open' or 'start' on Windows, but this only works if your codespace is hosted on the same machine that you're browsing to.
It would be great if there was a command that could be run that would open up the corresponding file in vscode, such that you could set the VIEW or EDITOR environment variables and have such operations edit in the file itself. Then (for example) running git in the integrated terminal would open a new vscode editor for writing the git message, instead of the default vi/emacs/notepad/edit.com/pico/nano.
Yes you can. Use the command:
code filename
Or, if you are running an early release (or GitHub codespaces):
code-insiders filename

How to open VS Code and pass commands to integrated termianal via CLI

I wonder how to use the code command to open the VS Code with the integrated terminal launching within with some commands running that I pass directly to the integrated terminal.
Right now I need to do a couple of actions to get it done:
open VS Code via code .
manually open the built-in terminal and run a command like npm run start
Maybe it's possible to open VS Code like this: code . --exec 'npm run start', and it may open the editor and also run another command in the integrated terminal just after VS Code is ready for work.
I look through the documentation and I couldn't find anything useful for this case. Maybe I need to look for something like plugin or tricky bash/zsh script?
Reminder: it’s important to run these “passed” commands via CLI directly in the integrated (built-in) terminal of the newly opened VS Code instance. I know that it's possible to open the editor and then run commands, like code . && npm run start, but it will be just another command in sequence after code, it's not the same as running commands in integrated terminal.
Thanks.

vscode automatically "source activate" everytime launches new terminal

Recently when I'm using vscode, everytime I launches the built-in terminal, it automatically uses "source activate base" to launch a anaconda python virtual environment. You can see the screenshot
I don't think I changed anything but it just came up randomly. Can someone help me out?
To prevent automatic activation of a selected environment, add
"python.terminal.activateEnvironment": false
to your settings.json file (it can be placed anywhere as a sibling to the existing settings). However, debugging or running Python code without any activated environment won't work.