MikeLemo
MikeLemo

Reputation: 651

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?

Upvotes: 38

Views: 61072

Answers (5)

xav_G
xav_G

Reputation: 11

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 !

Upvotes: 1

user2275093
user2275093

Reputation: 11

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

Upvotes: 0

R...
R...

Reputation: 2590

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",

Upvotes: 1

parthnamdev
parthnamdev

Reputation: 81

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!

Upvotes: 8

sunsun
sunsun

Reputation: 586

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.

Upvotes: 55

Related Questions