30

Few days ago I assume Microsoft released a new update for VSCode and when I came to build my esp idf project it didn't work because it relies on a command to run from the terminal before it's "special" project build command is executed and I came to the conclusion that the following setting that allowed that automatically was in file main.code.workspace in "settings" were:

    "terminal.integrated.shell.windows": "cmd.exe",
    "terminal.integrated.shellArgs.windows": [

        "/k", 
        "C:/Coding/ESP32/esp-idf/export.bat"
    ],

and the error is as follows:

This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile in #terminal.integrated.profiles.osx# and setting its profile name as the default in #terminal.integrated.defaultProfile.osx#. This will currently take priority over the new profiles settings but that will change in the future.

What is the new way to configure the default terminal at startup and run this command?

MikeLemo
  • 521
  • 1
  • 5
  • 11

5 Answers5

48

In the settings.json file we need to have the following

"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"
    },
    "Git Bash": {
        "source": "Git Bash"
    }
},

And set the default terminal by adding

"terminal.integrated.defaultProfile.windows": "Command Prompt",

We can achieve this by pressing Ctrl + Shift + P and searching for Terminal: Select Default Profile and selecting the required shell.

However, although deprecated the setting you have currently should work for now.

sunsun
  • 506
  • 3
  • 6
  • 3
    Thanks I've added this code block to my main.code-workspace file so it executes every time I load the workspace but how do you make it auto type these two commands at startup?: "/k", "C:/Coding/ESP32/esp-idf/export.bat" – MikeLemo Jun 06 '21 at 09:19
  • 2
    I believe you can add it in the args field like in this [comment](https://github.com/microsoft/vscode/issues/122355#issuecomment-833086902) so that it executes everytime. – sunsun Jun 28 '21 at 16:12
  • This is the correct answer but it's even easier since you **only** need `"terminal.integrated.defaultProfile.windows": "Command Prompt"`. This is because all that is written in the first code block are the default settings (unless you WANT to change something from the defaults...) – YoniChechik Sep 19 '21 at 12:39
  • "Git Bash" with a space doesn't work. See: https://dev.to/andrewriveradev/how-to-set-git-bash-as-integrated-terminal-in-vscode-2k31 – JoePC Jun 23 '22 at 18:28
8

I have solved this by

1)Add Git/bin to the path in env variables

2)Restart VSC and add the following in settings.json

"terminal.integrated.profiles.windows": {
    "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "icon": "terminal-cmd"
    },
    "GitBash": {
      "path": ["F:\\Program files\\Git\\bin\\bash.exe"],
      "icon": "terminal-bash"
    },
},
"terminal.integrated.defaultProfile.windows": "GitBash",

just replace 'your path of git bash' in path for "GitBash"

3)Remove old settings

for me it was

"terminal.integrated.shell.windows": "F:\\Program files\\Git\\bin\\bash.exe"

4)Save settings, Close terminal of VSC by pressing delete, restart VSC

Hope this works!

parthnamdev
  • 81
  • 1
  • 2
  • Thank you so much dude. This is the easiest way to do it. Really appreciate it. Don't know why it isn't the approved answer. – Faraz Zaidi Nov 14 '21 at 15:05
  • People have to take note of the program's path. Like I here, I'm using C drive, all I did was: ----> modify the path in the above to fit my system path i.e., `"path": ["C:\\Program files\\Git\\bin\\bash.exe"]` – Comsavvy Jul 27 '22 at 15:13
1

I recently upgraded to VSCode 1.60 on windows and having similar problem I added the above mentioned "GitBash" option to profiles but when I tried to use it like this:

   "terminal.integrated.defaultProfile.windows": "GitBash",

VSCode complained that "GitBash" is not a valid value:

Value is not accepted. Valid values: "PowerShell", "Command Prompt", "JavaScript Debug Terminal".

So instead I updated the "Command Prompt" profile to point to my git bash and this WORKED

    "terminal.integrated.profiles.windows": {
    "PowerShell": {
        "source": "PowerShell",
        "icon": "terminal-powershell"
      },
      "Command Prompt": {
        "path": [
          "C:\\<PATH TO MY bash.exe>",
        ],
        "args": [],
        "icon": "terminal-bash"
      }
  },
"terminal.integrated.defaultProfile.windows": "Command Prompt",
pref
  • 1,651
  • 14
  • 24
0

I had the same issue with VS Code v1.60.1 so I downgraded it to v1.59.1 (https://code.visualstudio.com/updates/v1_59) worked fine and also disable auto-update

  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 15 '21 at 23:03
0

With VSCode 1.76.2 under windows 11,

I added this in User settings.json to have git bash in terminal list:

"terminal.integrated.profiles.windows": {
    "GitBash": {
      "path": ["C:\\Git\\Git\\bin\\bash.exe"],
      "icon": "terminal-bash"
    },
},
"terminal.integrated.defaultProfile.windows": "GitBash",

Remove last line if you don't want this bash terminal as default.

Note: Don't put any space in "GitBash" name !

xav_G
  • 1