Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The new way to configure default shell and argument commands in VSCode?

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?

like image 470
MikeLemo Avatar asked May 19 '21 10:05

MikeLemo


Video Answer


3 Answers

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.

like image 175
sunsun Avatar answered Oct 22 '22 06:10

sunsun


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!

like image 36
parthnamdev Avatar answered Oct 22 '22 08:10

parthnamdev


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",
like image 1
pref Avatar answered Oct 22 '22 08:10

pref