The VS code Azure Functions extension automatically created a launch config for debugging my project locally.
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"justMyCode": false,
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
This works well. However, I'd like to use an external terminal to debug instead of the integrated one. According to this doc, there is an option for this case, but it does not work in my case. Still, this is supposed to work for others; but I'm told then the debugger must not attach to the process but instead launch it itself (type key in json). And I have not gotten this to work that way.
Do any of you have working debug config for the Functions/VScode/ExternalTerminal/Win combo?
Cheers
I tried to repro using this Kenichiro Nakamura site, got the same issue.
I have opened the external terminal and used the below commands to run the debug:
Creating a function in a new folder
mkdir debugmyfunction
cd debugmyfunction
func new -n debugtest --worker-runtime dotnet-isolated
There will be a list of triggers, I selected HttpTrigger and then run the command func start
3)
Set the breakpoint after the Main() function in the program.cs
As I'm using VS Code So after pressing F5, it asked me AzureWebJobsStorage is not configured, then I disabled it to false and run again.
or
Run this command by opening the another external terminal and moving to your project directory:
func start --dotnet-isolated-debug
By default, .Net Core is the process attached in my debug console.
Then it takes a bit of time and show the following
Output:
I'm on a Mac and trying to get VSCode to auto run a command when terminal is open. Everything I've tried either results in nothing happening or an error. Any and all help is much appreciated - thanks.
Settings.json below (the terminal opens but the command isn't run)
"terminal.integrated.profiles.osx": {
"/bin/zsh (migrated)": {
"path": "/Users/myname/.oh-my-zsh",
"args": [
"reload -b"
]
}
},
Write your command in ~/.zshrc
For example I wrote:
echo 'Hello my friend!'
Now every time I open terminal (in VS Code also) I got the message.
In Visual Studio Code you can now split the integrated terminal in half. I am using VSCode's tasks feature as well to run two tasks always at the same time. How can I make it so when I run a task it will automatically split the current terminal, using the new one for the task?
Basically I'm wanting to open VSCode, it should auto open the integrated terminal like normal, and then I can run my two tasks which should end me with a terminal split into three like so:
------------------------------------------------------
| default terminal | Task 1 | Task 2 |
------------------------------------------------------
EDIT (SOLVED):
VSCode has been updated to allow this now :D
https://code.visualstudio.com/updates/v1_31#_task-output-support-split-terminals
You can now configure tasks to show output in a split terminal panel instead of creating a new one. A task configuration can use the group attribute in the presentation section to define where the task's output should be shown.
When creating your task make sure to have the presentation.reveal option set to always and presentation.panel option set to new. That way the output is always revealed and a new terminal is created on every task run
Example:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run tests",
"type": "shell",
"command": "./scripts/test.sh",
"windows": {
"command": ".\\scripts\\test.cmd"
},
"group": "test",
"presentation": {
"reveal": "always",
"panel": "new"
}
}
]
}
More info at: Tasks in Visual Studio Code
EDIT: Since you want new tasks into split terminals, maybe this info helps. I don't think it is possible to do it: Launch task directly into split terminal
The following should work:
{
"type": "process",
"label": "terminal",
"command": "/bin/bash", // <-- your shell here
"args": [
"-l" // login shell for bash
],
"problemMatcher": [],
"presentation": {
"echo": false, // silence "Executing task ..."
"focus": true,
"group": "sxs", // some arbitrary name for the group
"panel": "dedicated"
},
"runOptions": {
"runOn": "folderOpen"
}
}
Here, I'm auto-launching (and setting the focus on) the terminal when the folder is opened in vscode -- and further tasks that share the same presentation.group gets placed in split terminals when they're run (with new vs. reused splits depending on their presentation.panel)
Note: For this example, you may or may not need the -l option depending on your settings for terminal.integrated.shell*, terminal.integrated.automationShell* and terminal.integrated.inheritEnv -- this issue has some discussion on what is involved in setting up the shell environment.
Direct support for this was added in the January 2019 update.
Setting the same name for the presentation.group property of each task will cause the tasks to appear in split terminals. From the VS Code documentation:
group: Controls whether the task is executed in a specific terminal group using split panes. Tasks in the same group (specified by a string value) will use split terminals to present instead of a new terminal panel.
You can use tmux to split your terminal not just inside vscode, but in all your terminals.
MacOS Installation
The easiest way to get started with tmux on a Mac is to use the Homebrew package manager.
If you don’t have Homebrew installed yet, open either Terminal or iTerm and paste the below command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Once Homebrew is installed, you can use brew to install tmux:
brew install tmux
Confirm that it installed by checking the version (note the uppercase V):
tmux -V
Ubuntu / Debian Linux Installation
Installation for Ubuntu is similar to Mac, except that we will be using the apt-get package manager that comes pre-installed. Note that we will have to run apt-get as sudo. This is because a user account won’t have enough privileges to install tmux, so sudo will allow us to install it as superuser.
Update apt-get to make sure we are on the latest and greatest:
sudo apt-get update
Install tmux:
sudo apt-get install tmux
Confirm that it installed by checking the version:
tmux -V
After installing
Use the tmux command to start a new session, then press ctrl/cmd + b and % for vertical split or " for horizontal split.
References
How to install tmux
Tmux cheatsheet
You can simply split the
terminal via shortcut:
Ctrl + Shift + 5
Note: Tested on version 1.36.1 or greater
I want to change integrated terminal to CMDER i use VS Code on Windows 8.1.
I checked the docs and also preference file, but I am confused
which line to change.
External Terminal
// Customizes which terminal to run on Windows.
"terminal.external.windowsExec": "%COMSPEC%",
// Customizes which terminal application to run on OS X.
"terminal.external.osxExec": "Terminal.app",
// Customizes which terminal to run on Linux.
"terminal.external.linuxExec": "xterm",
Integrated Terminal
// The path of the shell that the terminal uses on Linux.
"terminal.integrated.shell.linux": "sh",
// The command line arguments to use when on the Linux terminal.
"terminal.integrated.shellArgs.linux": [],
// The path of the shell that the terminal uses on OS X.
"terminal.integrated.shell.osx": "sh",
// The command line arguments to use when on the OS X terminal.
"terminal.integrated.shellArgs.osx": [],
// The path of the shell that the terminal uses on Windows. When using shells shipped with Windows (cmd, PowerShell or Bash on Ubuntu), prefer C:\Windows\sysnative over C:\Windows\System32 to use the 64-bit versions.
"terminal.integrated.shell.windows": "C:\\Windows\\system32\\cmd.exe",
// The command line arguments to use when on the Windows terminal.
"terminal.integrated.shellArgs.windows": [],
// Controls the font family of the terminal, this defaults to editor.fontFamily's value.
"terminal.integrated.fontFamily": "",
// Controls whether font ligatures are enabled in the terminal.
"terminal.integrated.fontLigatures": false,
// Controls the font size in pixels of the terminal, this defaults to editor.fontSize's value.
"terminal.integrated.fontSize": 0,
// Controls the line height of the terminal, this number is multipled by the terminal font size to get the actual line-height in pixels.
"terminal.integrated.lineHeight": 1.2,
// Controls whether the terminal cursor blinks.
"terminal.integrated.cursorBlinking": false,
// Controls whether locale variables are set at startup of the terminal, this defaults to true on OS X, false on other platforms.
"terminal.integrated.setLocaleVariables": false,
// A set of command IDs whose keybindings will not be sent to the shell and instead always be handled by Code. This allows the use of keybindings that would normally be consumed by the shell to act the same as when the terminal is not focused, for example ctrl+p to launch Quick Open.
"terminal.integrated.commandsToSkipShell": [
"editor.action.toggleTabFocusMode",
"workbench.action.debug.continue",
"workbench.action.debug.restart",
"workbench.action.debug.run",
"workbench.action.debug.start",
"workbench.action.debug.stop",
"workbench.action.quickOpen",
"workbench.action.showCommands",
"workbench.action.terminal.clear",
"workbench.action.terminal.copySelection",
"workbench.action.terminal.focus",
"workbench.action.terminal.focusNext",
"workbench.action.terminal.focusPrevious",
"workbench.action.terminal.kill",
"workbench.action.terminal.new",
"workbench.action.terminal.paste",
"workbench.action.terminal.runSelectedText",
"workbench.action.terminal.scrollDown",
"workbench.action.terminal.scrollDownPage",
"workbench.action.terminal.scrollToBottom",
"workbench.action.terminal.scrollToTop",
"workbench.action.terminal.scrollUp",
"workbench.action.terminal.scrollUpPage",
"workbench.action.terminal.toggleTerminal"
],
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.
Add a new "terminal.integrated.shell.windows": "C:\\Bin\\Cmder\\Cmder.exe" setting to the User Settings document on the right if it's not already there. This is so you aren't editing the Default Setting directly, but instead adding to it.
Save the User Settings file.
You can then access it with keys Ctrl+backtick by default.
It is possible to get this working in VS Code and have the Cmder terminal be integrated (not pop up).
To do so:
Create an environment variable "CMDER_ROOT" pointing to your Cmder
directory.
In (Preferences > User Settings) in VS Code add the following settings:
"terminal.integrated.shell.windows": "cmd.exe"
"terminal.integrated.shellArgs.windows": ["/k", "%CMDER_ROOT%\\vendor\\init.bat"]
I know is late but you can quickly accomplish that by just typing Ctrl+Shift+P and then type "default" - it will show an option that says:
Terminal: Select Default Shell
It will then display all the terminals available to you.
From Official Docs
Correctly configuring your shell on Windows is a matter of locating
the right executable and updating the setting. Below is a list of
common shell executables and their default locations.
There is also the convenience command Select Default Shell that can be
accessed through the command palette which can detect and set this for
you.
So you can open a command palette using ctrl+shift+p, use the command Select Default Shell, then it displays all the available command line interfaces, select whatever you want, VS code sets that as default integrated terminal for you automatically.
If you want to set it manually find the location of executable of your cli and open user settings of vscode(ctrl+,) then set
"terminal.integrated.shell.windows":"path/to/executable.exe"
Example for gitbash on windows7:
"terminal.integrated.shell.windows":"C:\\Users\\stldev03\\AppData\\Local\\Programs\\Git\\bin\\bash.exe",
For OP's terminal Cmder there is an integration guide, also hinted in the VS Code docs.
If you want to use VS Code tasks and encounter problems after switch to Cmder, there is an update to #khernand's answer. Copy this into your settings.json file:
"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.env.windows": {
"CMDER_ROOT": "[cmder_root]" // replace [cmder_root] with your cmder path
},
"terminal.integrated.shellArgs.windows": [
"/k",
"%CMDER_ROOT%\\vendor\\bin\\vscode_init.cmd" // <-- this is the relevant change
// OLD: "%CMDER_ROOT%\\vendor\\init.bat"
],
The invoked file will open Cmder as integrated terminal and switch to cmd for tasks - have a look at the source here. So you can omit configuring a separate terminal in tasks.json to make tasks work.
Starting with VS Code 1.38, there is also "terminal.integrated.automationShell.windows" setting, which lets you set your terminal for tasks globally and avoids issues with Cmder.
"terminal.integrated.automationShell.windows": "cmd.exe"
I was successful via settings > Terminal > Integrated > Shell: Linux
from there I edited the path of the shell to be /bin/zsh from the default /bin/bash
there are also options for OSX and Windows as well
#charlieParker - here's what i'm seeing for available commands in the command pallette
If you want to change the external terminal to the new windows terminal, here's how.
The method explained in the accepted answer has been deprecated, now the new recommended way to configure your default shell is by creating a terminal profile in #terminal.integrated.profiles.windows# and setting its profile name as the default in #terminal.integrated.defaultProfile.windows#.
The old method will currently take priority over the new profiles settings but that will change in the future.
See an example for powershell taken from the docs
{
"terminal.integrated.profiles.windows": {
"My PowerShell": {
"path": "pwsh.exe",
"args": ["-noexit", "-file", "${env:APPDATA}PowerShellmy-init-script.ps1"]
}
},
"terminal.integrated.defaultProfile.windows": "My PowerShell"
}
change external terminal
windows terminal , which has been mentioned by others, is an alternative of alacrity, which is a terminal (emulator)
As stated in vscode, Cmder is a shell, just like powershell or bash.
"terminal.integrated.profiles.windows": {
"cmder": {
// "path": "F:\\cmder\\Cmder.exe", // 这样会开external terminal
"path": "C:\\WINDOWS\\System32\\cmd.exe",
"args": ["/K", "F:\\cmder\\vendor\\bin\\vscode_init.cmd"]
}
},
"terminal.integrated.profiles.linux": { "zsh": { "path": "zsh" }, },
"terminal.integrated.defaultProfile.windows": "PowerShell",
The statment in cmder' repo is misleading
Different shells under a terminal:
If you want to change the external terminal to the new windows terminal, here's how.
Probably it is too late but the below thing worked for me:
Open Settings --> this will open settings.json
type terminal.integrated.windows.shell
Click on {} at the top right corner -- this will open an editor where this setting can be over ridden.
Set the value as terminal.integrated.windows.shell: C:\\Users\\<user_name>\\Softwares\\Git\\bin\\bash.exe
Click Ctrl + S
Try to open new terminal. It should open in bash editor in integrated mode.
Working as of 02-Dec-2021.
In settings.json
{
"go.toolsManagement.autoUpdate":true,
"terminal.integrated.profiles.windows":{
"My Bash":{
"path":"D:\\1. Installed_Software\\Git\\bin\\bash.exe"
}
},
"terminal.integrated.defaultProfile.windows":"My Bash"
}
Reference: https://code.visualstudio.com/docs/editor/integrated-terminal#_terminal-profiles
I set up a build system in Sublime Text 3 to run Matlab files. This works really fine:
{
"cmd": ["/usr/local/MATLAB/R2013b/bin/matlab", "-nosplash", "-nodesktop", "-nojvm", "-r \"run('$file');\""]
}
The problem is I want to keep Matlab running in the Sublime console after $file is executed. Is this possible?
Thank you in advance.
Ok, I've finally found a solution that runs the build system in an external xterm terminal. If you use this Sublime will open a xterm window and execute the build system there. This window remains open, so e.g. Matlab plot windows will not be closed after execution of the code. I've combined the build system with and without the external terminal into one build system:
{
"cmd": ["/usr/local/MATLAB/R2013b/bin/matlab", "-nosplash", "-nodesktop", "-r \"run('$file');quit;\""],
"selector": "source.m",
"variants": [
{
"name": "xterm",
"cmd": ["xterm", "-e", "/usr/local/MATLAB/R2013b/bin/matlab", "-nosplash", "-nodesktop", "-r \"run('$file');\""]
}
]
}
and then assigned a user key binding to access the xterm variant easily:
[
{ "keys": ["ctrl+shift+b"], "command": "build", "args": {"variant": "xterm"} }
]
This xterm solution should also work with any other interpreter that you want to prevent from being closed after code execution finishes.
An alternative method is to have both Sublime and Matlab open and then set up a script with AutoHotKey (Windows) or Autokey (Linux) that copies the filename or the code to evaluate and then pastes this in Matlab's command window.
The benefits of this method are:
You maintain all of the useful features of MatLab as an IDE
You can evaluate code snippets (the F9 feature) as well as the whole file
See detailed instructions for Linux or Windows