Home > front end >  How to prevent VSCode to load powershell profile?
How to prevent VSCode to load powershell profile?

Time:05-31

I have looked at VSCode settings, I can't see clearly what "integrated" means that's what I have but it loads external powershell profile. I want to prevent it to do so, is it possible ?

P.S. : I don't have and don't want powershell extensions, should I to have this option ?

Update: As suggested I have unchecked "powershell.enableProfileLoading" both in User and Workspace settings, relaunched vscode, but in terminal still gets "Loading personal and system profiles took" weirdly it still doesn't work for me ?

Is it possible this is a VSCode settings bug ?

CodePudding user response:

  • If you DO have Visual Studio Code's PowerShell extension installed and you want to suppress loading of profiles in its special-purpose shell, the PowerShell Integrated Console (PIC):

    • GUI option: Via the Settings dialog, uncheck the option PowerShell: Enable Profile Loading

    • Settings.json file option: As Santiago Squarzon states, add the following setting:

      • "powershell.enableProfileLoading": false
  • If you do NOT have the PowerShell extension installed OR you (also) want to control profile loading for general-purpose PowerShell sessions running in Visual Studio's integrated terminal:

    • In the Settings dialog, search for terminal profiles and click on the Edit in settings.json link next to the platform-appropriate Terminal › Integrated › Profiles: <os> entry, where <os> is one of windows, linux or osx (macOS).

    • This will open your Settings.json file for editing and either create or navigate to a preexisting "terminal.integrated.profiles.<os>"object, which contains the profiles of all shells available in the integrated terminal.

    • Locate the PowerShell profile and add an "args": [ "-noprofile" ] property in order to suppress profile loading, which passes the -noprofile parameter to the PowerShell CLI (powershell.exe for Windows PowerShell, pwsh for PowerShell (Core) 7 ) on startup; e.g., on Windows:

"terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell",
            "args": [ "-noprofile" ]
        },
        // ...
}
  • Related